|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Room
Don't panic! You don't have to understand the implementation of
this class; just see the documentation of method
moveToDirection
.
Class Room
describes a room that may contain some objects and that may be
connected to other rooms by doors. The implementation of the class
is rather complicated.
Constructor Summary | |
Room(String name)
Constructs a new room. |
Method Summary | |
void |
addObject(Object item)
Inserts an object to a room. |
void |
connect(Room other,
int direction)
Connects two rooms. |
boolean |
containsObject(Object item)
Does this room contain the given object? |
Object |
getObjectAt(int index)
Retrieves the n'th object in this room. |
boolean |
moveToDirection(Robot robot,
int direction)
Tries to move a robot to the given direction. |
boolean |
possibleDirection(int direction)
Is this room connected to another room in the given direction? |
boolean |
removeObject(Object item)
Removes an object from a room. |
String |
toString()
Redefine the predefined toString method. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public Room(String name)
name
- The name of the room. May be any string.Method Detail |
public void connect(Room other, int direction)
other
- the other room that is connected to this room.direction
- the direction of the connection.public boolean possibleDirection(int direction)
direction
- the direction of the connection.true
if there is door to another room in
the given direction and
false
if there is no such door.public void addObject(Object item)
item
- the object that we insert to this room.public boolean removeObject(Object item)
item
- the object that we remove from this room.true
if the room contained the given
object and false
if it did not.public boolean containsObject(Object item)
item
- the object that we check.true
if the room contained the given
object and false
if it did not.public Object getObjectAt(int index)
index
- the index of the object.null
if it did not.public boolean moveToDirection(Robot robot, int direction)
robot
- the robot to be moveddirection
- the direction of the movetrue
if the move was possible and
false
otherwise.public String toString()
toString
method.
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |