Advertisement
mbah_bejo

Room

Nov 15th, 2020
978
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1. /**
  2.  * Class Room - sebuah room dalam game adventure.
  3.  *
  4.  * Class ini adalah bagian dari "World of Zuul".
  5.  * "World of Zuul" sangat simple, game adventure berbasis text.  
  6.  *
  7.  * sebuah "Room" mewakili satu lokasi dalam pemandangan dari game. Terhubung ke kamar lain
  8.  * melalui pintu keluar. Pintu keluar diberi label north, east,
  9.  * south, west.  Untuk setiap arah, room tersebut menyimpan referensi
  10.  * ke room yang bersebelahan, atau null ika tidak ada jalan keluar ke arah tersebut.
  11.  *
  12.  * @author  thomasdwi.a
  13.  * @version 20201115
  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.      * membuat room dengan deskripsi "description". awalnya, tidak ada pintu keluar/
  25.      * "description" itu seperti "a kitchen" atau "an open court yard".
  26.      *
  27.      * @param description Deskripsi room.
  28.      */
  29.     public Room(String description)
  30.     {
  31.         this.description = description;
  32.     }
  33.  
  34.     /**
  35.      * Menentukan pintu keluar room ini. Setiap arah mengarah ke
  36.      * ruangan lain atau null (tidak ada jalan keluar di sana).
  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 deskripsi room.
  56.      */
  57.     public String getDescription()
  58.     {
  59.         return description;
  60.     }
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement