|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Room
public class Room
This class represents a Room within our game. For full details of the Room class, see HW J7.
Constructor Summary | |
---|---|
Room()
Creates a default Room object, with the description "A nondescript room" |
|
Room(java.lang.String desc)
Creates a Room object with the passed String as the description |
|
Room(java.lang.String desc,
Creature occupant,
Weapon weap)
Creates a Room object with the passed parameters |
Method Summary | |
---|---|
Room |
enterRoom(Creature player)
The main method for doing an action within a room. |
int |
getCol()
Returns the column where this Room object is located within the 2-dimensional array in the Map |
java.lang.String |
getDescription()
Returns the String description of this Room |
Weapon |
getItem()
Returns the weapon (if any) in this Room; |
Creature |
getMonster()
Returns the creature (if any) in this Room; |
Room |
getRoomToEast()
Gets the Room through the east door of this Room |
Room |
getRoomToNorth()
Gets the Room through the north door of this Room |
Room |
getRoomToSouth()
Gets the Room through the south door of this Room |
Room |
getRoomToWest()
Gets the Room through the west door of this Room |
int |
getRow()
Returns the row where this Room object is located within the 2-dimensional array in the Map |
void |
printDescription()
Prints the description of the room to standard output. |
void |
setColRow(int c,
int r)
Sets the column and row where this Room object is located within the 2-dimensional array in the Map |
void |
setDescription(java.lang.String str)
Sets the String description of this Room |
void |
setItem(Weapon w)
Sets the weapon (if any) in this Room; |
void |
setMonster(Creature c)
Sets the creature (if any) to put in this Room; |
void |
setRoomToEast(Room r)
Sets the Room through the east door of this Room |
void |
setRoomToNorth(Room r)
Sets the Room through the north door of this Room |
void |
setRoomToSouth(Room r)
Sets the Room through the south door of this Room |
void |
setRoomToWest(Room r)
Sets the Room through the west door of this Room |
java.lang.String |
toString()
Generates a String representation of this Room object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Room()
public Room(java.lang.String desc)
desc
- The description for this Roompublic Room(java.lang.String desc, Creature occupant, Weapon weap)
desc
- The description for this Roomoccupant
- The creature (if any) to put in this Room; null
ensures no occupant.weap
- The weapon (if any) to put in this Room; null
ensures no weaponMethod Detail |
---|
public void setColRow(int c, int r)
Map
c
- The column of this Room objectr
- The row of this Room objectpublic int getRow()
Map
public int getCol()
Map
public java.lang.String toString()
toString
in class java.lang.Object
public Room getRoomToNorth()
public void setRoomToNorth(Room r)
r
- The Room that should be set to be the Room through the
north door of this Roompublic Room getRoomToEast()
public void setRoomToEast(Room r)
r
- The Room that should be set to be the Room through the
east door of this Roompublic Room getRoomToSouth()
public void setRoomToSouth(Room r)
r
- The Room that should be set to be the Room through the
south door of this Roompublic Room getRoomToWest()
public void setRoomToWest(Room r)
r
- The Room that should be set to be the Room through the
west door of this Roompublic java.lang.String getDescription()
public void setDescription(java.lang.String str)
str
- The new String description of this Roompublic Creature getMonster()
public void setMonster(Creature c)
c
- The creature (if any) to put in this Room; null
ensures no occupant.public Weapon getItem()
public void setItem(Weapon w)
w
- The weapon (if any) to put in this Room; null
ensures no weapon.public void printDescription()
public Room enterRoom(Creature player)
Parser.parse()
), then takes the appropriate action based on
that command. See HW J7 for
more details about what actions are taken on each input.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |