|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectinfo.gridworld.actor.Actor
info.gridworld.actor.Bug
public class Bug
A Bug
is an actor that can move and turn. It drops flowers as
it moves.
The implementation of this class is testable on the AP CS A and AB exams.
Constructor Summary | |
---|---|
Bug()
Constructs a red bug. |
|
Bug(Color bugColor)
Constructs a bug of a given color. |
Method Summary | |
---|---|
void |
act()
Moves if it can move, turns otherwise. |
boolean |
canMove()
Tests whether this bug can move forward into a location that is empty or contains a flower. |
void |
move()
Moves the bug forward, putting a flower into the location it previously occupied. |
void |
turn()
Turns the bug 45 degrees to the right without changing its location. |
Methods inherited from class info.gridworld.actor.Actor |
---|
getColor, getDirection, getGrid, getLocation, moveTo, putSelfInGrid, removeSelfFromGrid, setColor, setDirection, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Bug()
public Bug(Color bugColor)
bugColor
- the color for this bugMethod Detail |
---|
public void act()
act
in class Actor
public void turn()
public void move()
public boolean canMove()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |