Loyola College in Maryland
CS 201 - Computer Science I
Fall, 2002
Loyola College >
Department of Computer Science >
CS 201 >
Examples >
Lecture 16
A few review questions covering variables, expressions, and assignments
are available as a PDF file.
Capabilities for the classes from the in-class exercise are given below.
The goal is to get three boxes on the chalkboard: an empty one and one
with a six-pointed star on the left and one with one row of 3 lines and
another row of 2 on the right.
I suggest you start by making a professor and asking him to explain what to
do (but you must speak in Java).
Professor
- Professor() creates a new professor
- explain() makes this professor explain what you're doing
- pickUp(Chalk c) makes this professor pick up the given piece of chalk, putting down any he is currently holding
- drawStar(Box b) makes this professor draw a five-pointed star in the given box with the piece of chalk he's currently holding; if he has no chalk then nothing happens
- drawStar(Box b, int points) like the previous method, but allows you to specify the kind of star to draw
- drawLine(Box b, int howMany) makes this professor draw the given number of lines in the given box, starting below where he last drew lines in that box (if any); nothing happens if he has no chalk
- erase(Box b, Eraser e) makes this professor erase the contents
of this given box with the given eraser
Chalk
- Chalk() creates a new piece of chalk
Eraser
- Eraser() creates a new eraser
Box
- Box(int board) creates a new box on the given chalkboard