Class Room

java.lang.Object
  extended by Room

public class Room
extends Object

Represents a room in the game

Version:
1.0

Constructor Summary
Room(String description)
          Constructor for objects of type Room
 
Method Summary
 void addItem(Item newItem)
          Adds a new item to the room
 String getDescription()
          Returns the description of the room
 Room getExit(String direction)
          Return the room that is reached if we go from this room in direction "direction".
 Item getItem(String description)
          Returns the item with a specified description
 ArrayList<Item> getItems()
          Returns the items in the room
 void removeItem(String description)
          Removes the specified item from the room
 void setExit(String direction, Room neighbor)
          Define an exit from this room.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Room

public Room(String description)
Constructor for objects of type Room

Parameters:
description - a description of the room
Method Detail

addItem

public void addItem(Item newItem)
Adds a new item to the room

Parameters:
newItem - the item to add

getDescription

public String getDescription()
Returns the description of the room

Returns:
the description

getExit

public Room getExit(String direction)
Return the room that is reached if we go from this room in direction "direction". If there is no room in that direction, return null.

Parameters:
direction - The exit's direction.
Returns:
The room in the given direction.

getItem

public Item getItem(String description)
Returns the item with a specified description

Parameters:
description - the description of the specified item
Returns:
the specified item

getItems

public ArrayList<Item> getItems()
Returns the items in the room

Returns:
the items

removeItem

public void removeItem(String description)
Removes the specified item from the room

Parameters:
description - the description of the specified item

setExit

public void setExit(String direction,
                    Room neighbor)
Define an exit from this room.

Parameters:
direction - The direction of the exit.
neighbor - The room to which the exit leads.