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

bomb squad room 1

By: ace on Jul 7th, 2010  |  syntax: None  |  size: 1.89 KB  |  hits: 25  |  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. /*
  2.  * Class Room - a room in an adventure game.
  3.  *
  4.  * This class is part of the "World of Zuul" application.
  5.  * "World of Zuul" is a very simple, text based adventure game.  
  6.  *
  7.  * A "Room" represents one location in the scenery of the game.  It is
  8.  * connected to other rooms via exits.  The exits are labelled north,
  9.  * east, south, west.  For each direction, the room stores a reference
  10.  * to the neighboring room, or null if there is no exit in that direction.
  11.  *
  12.  * @author  Michael Kolling and David J. Barnes
  13.  * @version 1.0 (February 2002)
  14.  */
  15.  
  16. public class Room
  17. {
  18.     private String description;
  19.     private Room northExit;
  20.     private Room southExit;
  21.     private Room eastExit;
  22.     private Room westExit;
  23.  
  24.     /**
  25.      * Create a room described "description". Initially, it has
  26.      * no exits. "description" is something like "a kitchen" or
  27.      * "an open court yard".
  28.      */
  29.     public Room(String description)
  30.     {
  31.         this.description = description;
  32.     }
  33.  
  34.     /**
  35.      * Define the exits of this room.  Every direction either leads
  36.      * to another room or is null (no exit there).
  37.      */
  38.     public void setExits(Room north, Room east, Room south, Room west)
  39.     {
  40.         if(north != null)
  41.             northExit = north;
  42.         if(east != null)
  43.             eastExit = east;
  44.         if(south != null)
  45.             southExit = south;
  46.         if(west != null)
  47.             westExit = west;
  48.     }
  49.  
  50.     /**
  51.      * Return the description of the room (the one that was defined
  52.      * in the constructor).
  53.      */
  54.     public String getDescription()
  55.     {
  56.         return description;
  57.     }
  58.    
  59.     public Room getExit(String direction)
  60. {
  61. if(direction.equals("north"))
  62. return northExit;
  63. if(direction.equals("east"))
  64. return eastExit;
  65. if(direction.equals("south"))
  66. return southExit;
  67. if(direction.equals("west"))
  68. return westExit;
  69. return null;
  70. }
  71.  
  72.  
  73. }