Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

ShorterNameGenComplete

By: ace on Apr 9th, 2010  |  syntax: None  |  size: 1.37 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.util.HashMap;
  2. // class comment omitted
  3. class Room
  4. {
  5.     private String description;
  6.     private HashMap<Room> exits;
  7.     /**
  8.      * Create a room described "description". Initially, it has
  9.      * no exits. "description" is something like "a kitchen" or
  10.      * "an open court yard".
  11.      */
  12.     public Room(String description)
  13.     {
  14.         this.description = description;
  15.         exits = new HashMap<Room>();
  16.     }
  17.     /**
  18.      * Define the exits of this room. Every direction either leads
  19.      * to another room or is null (no exit there).
  20.      */
  21.     public void setExits(Room north, Room east, Room south,
  22.                           Room west)
  23.     {
  24.         if(north != null)
  25.             exits.put("north", north)
  26.         if(east != null)
  27.             exits.put("east", east)
  28.         if(south != null)
  29.             exits.put("south", south)
  30.         if(west != null)
  31.             exits.put("west", west)
  32.     }
  33.     /**
  34.      * Return the room that is reached if we go from this room in
  35.      * direction "direction". If there is no room in that
  36.      * direction, return null.
  37.      */
  38.     public Room getExit(String direction)
  39.     {
  40.         return exits.get(direction);
  41.     }
  42.  
  43.   /**
  44.    * Return the description of the room (the one that was defined
  45.    * in the constructor).
  46.    */
  47.   public String getDescription()
  48.   {
  49.       return description;
  50.   }
  51. }