Class Room

java.lang.Object
  extended by Room

public class Room
extends java.lang.Object

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

Room

public Room()
Creates a default Room object, with the description "A nondescript room"


Room

public Room(java.lang.String desc)
Creates a Room object with the passed String as the description

Parameters:
desc - The description for this Room

Room

public Room(java.lang.String desc,
            Creature occupant,
            Weapon weap)
Creates a Room object with the passed parameters

Parameters:
desc - The description for this Room
occupant - 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 weapon
Method Detail

setColRow

public 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

Parameters:
c - The column of this Room object
r - The row of this Room object

getRow

public int getRow()
Returns the row where this Room object is located within the 2-dimensional array in the Map

Returns:
The row for this Room object

getCol

public int getCol()
Returns the column where this Room object is located within the 2-dimensional array in the Map

Returns:
The column for this Room object

toString

public java.lang.String toString()
Generates a String representation of this Room object. The description, column, and row (in that order) are printed.

Overrides:
toString in class java.lang.Object
Returns:
The String representation of this Room object.

getRoomToNorth

public Room getRoomToNorth()
Gets the Room through the north door of this Room

Returns:
The Room through the north door of this Room

setRoomToNorth

public void setRoomToNorth(Room r)
Sets the Room through the north door of this Room

Parameters:
r - The Room that should be set to be the Room through the north door of this Room

getRoomToEast

public Room getRoomToEast()
Gets the Room through the east door of this Room

Returns:
The Room through the east door of this Room

setRoomToEast

public void setRoomToEast(Room r)
Sets the Room through the east door of this Room

Parameters:
r - The Room that should be set to be the Room through the east door of this Room

getRoomToSouth

public Room getRoomToSouth()
Gets the Room through the south door of this Room

Returns:
The Room through the south door of this Room

setRoomToSouth

public void setRoomToSouth(Room r)
Sets the Room through the south door of this Room

Parameters:
r - The Room that should be set to be the Room through the south door of this Room

getRoomToWest

public Room getRoomToWest()
Gets the Room through the west door of this Room

Returns:
The Room through the west door of this Room

setRoomToWest

public void setRoomToWest(Room r)
Sets the Room through the west door of this Room

Parameters:
r - The Room that should be set to be the Room through the west door of this Room

getDescription

public java.lang.String getDescription()
Returns the String description of this Room

Returns:
The String description of this Room

setDescription

public void setDescription(java.lang.String str)
Sets the String description of this Room

Parameters:
str - The new String description of this Room

getMonster

public Creature getMonster()
Returns the creature (if any) in this Room;

Returns:
The creature (if any) in this Room; null if there is no occupant.

setMonster

public void setMonster(Creature c)
Sets the creature (if any) to put in this Room;

Parameters:
c - The creature (if any) to put in this Room; null ensures no occupant.

getItem

public Weapon getItem()
Returns the weapon (if any) in this Room;

Returns:
The weapon (if any) in this Room; null if there is no weapon.

setItem

public void setItem(Weapon w)
Sets the weapon (if any) in this Room;

Parameters:
w - The weapon (if any) to put in this Room; null ensures no weapon.

printDescription

public void printDescription()
Prints the description of the room to standard output. Also printed is whether there is a weapon and/or a creature in the room as well. Lastly, the exits are printed.


enterRoom

public Room enterRoom(Creature player)
The main method for doing an action within a room. This method reads in a command from the keyboard (via 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.