student.adventure
Class Room

java.lang.Object
  extended by student.adventure.Room

public class Room
extends java.lang.Object

Represents one location in the scenery of an adventure game. It is connected to other rooms via exits. For each existing exit, the room stores a reference to the neighboring room.

Version:
1.0 (February 2002)
Author:
Michael Kolling and David J. Barnes

Constructor Summary
Room(java.lang.String description)
          Create a room described "description".
 
Method Summary
 Room getExit(java.lang.String direction)
          Return the room that is reached if we go from this room in direction "direction".
 java.lang.String getLongDescription()
          Return a long description of this room, including a list of available exits.
 java.lang.String getShortDescription()
          Return the description of the room (the one that was defined in the constructor).
 void setExit(java.lang.String direction, Room neighbor)
          Define an exit from this room.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Room

public Room(java.lang.String description)
Create a room described "description". Initially, it has no exits. "description" is something like "in a kitchen" or "in an open court yard".

Parameters:
description - The room's description
Method Detail

setExit

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

Parameters:
direction - The direction of the exit
neighbor - The room connected to this one in the given direction

getShortDescription

public java.lang.String getShortDescription()
Return the description of the room (the one that was defined in the constructor).

Returns:
The room's description

getLongDescription

public java.lang.String getLongDescription()
Return a long description of this room, including a list of available exits. The description is phrased in this form:
     You are in the kitchen.
     Exits: north west
 

Returns:
The room's description (prefixed with "You are " and followed by a period), together with the room's getExitString().

getExit

public Room getExit(java.lang.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 direction to travel
Returns:
the neighboring room in the given direction