Fill out the pre-term survey if you haven't already
Fill out the daily survey with your name, at least once, if you haven't already
Warm-up (in case you're not ready to plunge
into problem P7.2 yet):
any of P5.8, P5.9, P5.11, P5.14, P5.15, P5.16, Project 5.1,
Project 5.2
Exercise P7.2, page 270 of the textbook. Write a program that draws a 10x10 street grid with a "drunkard" wandering randomly on it. Specifically, at each step the "drunkard" chooses randomly whether to go one block north, one block south, one block east, or one block west. The drunkard should take 100 steps. Use classes for the grid and the drunkard.
Practical details: Based on what the text has shown
you to this point, I recommend writing a
Grid
class which extends JComponent
, and
putting the for
-loop
(counting 100 steps) inside the paintComponent
method of
this class. As the book says, you should have a separate class for the
drunkard (imagine, for example, a last-minute change to the assignment
that requires there to be two drunkards; how would you handle
this?)
Every "interesting" method in your program should, if possible, be accompanied by a "testing" method that runs various test cases on it and returns true or false indicating whether it passed all its tests. (Some methods don't lend themselves to this kind of testing, in which case you should describe, in English, how you would test them and tell whether they were working correctly.)
While you work on this program, keep an error log recording mistakes you make. For each one, write down
Pre-term Survey: /5
(I'm not grading on what you say, only on whether you filled it out.)
"Daily" Survey: /5
(Ditto.)
Error log: /20
(I'm not grading on how many or how few errors you encountered,
only on whether you recorded them adequately.)
The program(s):
/100
I'll grade on several criteria:
Following directions | /10 |
Choosing contracts/interfaces for classes and methods | /10 |
Choosing test cases | /10 |
Choosing names | /10 |
Coding | /10 |
Code re-use and object-oriented design | /10 |