bagusistighfar86

Untitled

Nov 17th, 2020
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.88 KB | None | 0 0
  1.  
  2. /**
  3.  * room class - room dalam game petualangan.
  4.  *
  5.  *  kelas ini adalah kelas utama dari aplikasi "world of Zuul".
  6.  * "World of Zuul" adalah game petualangan berbasis teks yang sangat sederhana.
  7.  *
  8.  * Sebuah "Room" mewakili satu lokasi dalam pemandangan permainan. ini
  9.  * terhubung ke kamar lain melalui pintu keluar. Pintu keluarnya diberi label utara,
  10.  * timur, selatan, barat. Untuk setiap arah, ruangan menyimpan referensi
  11.  * ke ruang tetangga, atau nol jika tidak ada jalan keluar ke arah itu.
  12.  *
  13.  * @author (Muhammad Bagus Istighfar)
  14.  * @version 0.1 - 17 November 2020
  15.  */
  16. public class Room
  17. {
  18.     public String description;
  19.     public Room northExit;
  20.     public Room southExit;
  21.     public Room eastExit;
  22.     public 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.      * @param String description
  30.      */
  31.     public Room(String description)
  32.     {
  33.         this.description = description;
  34.     }
  35.  
  36.     /**
  37.      * Define the exits of this room. Every direction either leads
  38.      * to another room or is null (no exit there).
  39.      *
  40.      * @param north The north exit.
  41.      * @param east The east east.
  42.      * @param south The south exit.
  43.      * @param west The west exit.
  44.      */
  45.     public void setExits(Room north, Room east, Room south, Room west)
  46.     {
  47.         if(north != null)
  48.             northExit = north;
  49.         if(east != null)
  50.             eastExit = east;
  51.         if(south != null)
  52.             southExit = south;
  53.         if(west != null)
  54.             westExit = west;
  55.     }
  56.  
  57.     /**
  58.      * Return the description of the room (the one that was defined
  59.      * in the constructor)
  60.      *
  61.      * @return String description.
  62.      */
  63.     public String getDescription()
  64.     {
  65.         return description;
  66.     }
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment