Class Room

java.lang.Object
  extended by Room

public class Room
extends java.lang.Object

Class Room - a room in an adventure game. This class is part of the "World of Zuul" application. "World of Zuul" is a very simple, text based adventure game. A "Room" represents one location in the scenery of the game. It is connected to other rooms via exits. For each existing exit, the room stores a reference to the neighboring room.

Version:
2011.07.31
Author:
Michael Kolling and David J. Barnes

Field Summary
private  java.lang.String description
           
private  java.util.HashMap<java.lang.String,Room> exits
           
 
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".
private  java.lang.String getExitString()
          Return a string describing the room's exits, for example "Exits: north west".
 java.lang.String getLongDescription()
          Return a long description of this room, in the form: You are in the kitchen.
 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

description

private java.lang.String description

exits

private java.util.HashMap<java.lang.String,Room> exits
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".

Method Detail

setExit

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


getShortDescription

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


getLongDescription

public java.lang.String getLongDescription()
Return a long description of this room, in the form: You are in the kitchen. Exits: north west


getExitString

private java.lang.String getExitString()
Return a string describing the room's exits, for example "Exits: north west".


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.