|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Robot
This class describes a simple robot that can move forward, turn 90 degree to the left and to the right, and test the possibility of a forward move. The robot has a direction: it looks either to the north, east, south, or west. In this program, the direction is presented by an integer:
Constructor Summary | |
Robot(int direction)
Creates a new robot that looks to the given direction. |
Method Summary | |
Room |
getRoom()
In which room is this robot located at? |
String |
label()
One letter string describing the direction of this robot. |
void |
setRoom(Room room)
Sets the room in which this robot is located at. |
void |
solve(Maze m,
Room goal)
The method tries to move this robot from the current room to the goal room in a maze. |
boolean |
stepForward()
You should implement this in exercise 2.1. |
boolean |
testForward()
You should implement this in exercise 2.1. |
String |
toString()
Redefine the predefined toString method. |
void |
turnLeft()
You should implement this in exercise 2.1. |
void |
turnRight()
You should implement this in exercise 2.1. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public Robot(int direction)
Method Detail |
public Room getRoom()
null
if the robot is in no room.public void setRoom(Room room)
room
- the new location of this robot.public boolean testForward()
true
if a forward move is possible and
false
if it is not.public boolean stepForward()
true
if a forward move is possible and
false
if it is not.public void turnLeft()
public void turnRight()
public String label()
public String toString()
toString
method.public void solve(Maze m, Room goal)
m
- a maze containing the robotgoal
- the goal room
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |