|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectCaterpillar
public class Caterpillar
Caterpillars, for use in the Munch Game
MunchGame| Constructor Summary | |
|---|---|
Caterpillar(java.awt.Color c,
java.awt.Point sp,
int len,
int loc)
Construct a new caterpillar with the given color and starting position. |
|
| Method Summary | |
|---|---|
int |
getScore()
Get the caterpillar's score. |
void |
move(MunchGame game)
Move the caterpillar one step. |
boolean |
onPosition(java.awt.Point newPos)
Determine whether any part of the caterpillar's body lies on the given position. |
void |
paint(java.awt.Graphics g)
Draw this caterpillar on the given graphics pane and draw its score in the appropriate location. |
void |
setDirection(char d)
Set the direction of the head of the caterpillar. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Caterpillar(java.awt.Color c,
java.awt.Point sp,
int len,
int loc)
c - this caterpillar's colorsp - this caterpillar's starting position (a point on the grid)len - the caterpillar's length (number of body segments)loc - the x coordinate of this caterpillar's score| Method Detail |
|---|
public void setDirection(char d)
d - the direction (N, S, E, or W) or pause command (Z)public int getScore()
public void move(MunchGame game)
game - the current state of the caterpillar gamepublic boolean onPosition(java.awt.Point newPos)
newPos - the position to test
public void paint(java.awt.Graphics g)
g - the graphics pane on which to draw the caterpillar
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||