Advertisement
lamaulfarid

Room

Nov 19th, 2020
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.72 KB | None | 0 0
  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 Ahmad Lamaul Farid
  13. * @version 12 November 2020
  14. */
  15. public class Room
  16. {
  17.     public String description;
  18.     public Room northExit;
  19.     public Room southExit;
  20.     public Room eastExit;
  21.     public Room westExit;
  22.      
  23.     /**
  24.     * Create a room described "description". Initially, it has
  25.     * no exits. "description" is something like "a kitchen" or
  26.     * "an open court yard".
  27.     * @param description The room's description.
  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.     * @param north The north exit.
  38.     * @param east The east east.
  39.     * @param south The south exit.
  40.     * @param west The west exit.
  41.     */
  42.     public void setExits(Room north, Room east, Room south, Room west)
  43.     {
  44.         if(north != null)
  45.             northExit = north;
  46.         if(east != null)
  47.             eastExit = east;
  48.         if(south != null)
  49.             southExit = south;
  50.         if(west != null)
  51.             westExit = west;
  52.     }
  53.      
  54.     /**
  55.     * @return The description of the room.
  56.     */
  57.     public String getDescription()
  58.     {
  59.         return description;
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement