Advertisement
raffi_pratama

Untitled

Nov 16th, 2020
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.68 KB | None | 0 0
  1.  
  2. /**
  3.  * sebuah "Room" mewakili satu lokasi dalam pemandangan dari game. Terhubung ke kamar lain
  4.  * melalui pintu keluar. Pintu keluar diberi label north, east,
  5.  * south, west.  Untuk setiap arah, room tersebut menyimpan referensi
  6.  * ke room yang bersebelahan, atau null ika tidak ada jalan keluar ke arah tersebut.
  7.  *
  8.  * @author  M. Rayhan Raffi P.
  9.  
  10.  * @version 16-11-2020
  11.  
  12.  */
  13.  
  14. public class Room
  15.  
  16. {
  17.  
  18.     public String description;
  19.  
  20.     public Room northExit;
  21.  
  22.     public Room southExit;
  23.  
  24.     public Room eastExit;
  25.  
  26.     public Room westExit;
  27.  
  28.  
  29.  
  30.     /**
  31.  
  32.      * Create a room described "description". Initially, it has
  33.  
  34.      * no exits. "description" is something like "a kitchen" or
  35.  
  36.      * "an open court yard".
  37.  
  38.      * @param description The room's description.
  39.  
  40.      */
  41.  
  42.     public Room(String description)
  43.  
  44.     {
  45.  
  46.         this.description = description;
  47.  
  48.     }
  49.  
  50.  
  51.  
  52.     /**
  53.  
  54.      * Define the exits of this room.  Every direction either leads
  55.  
  56.      * to another room or is null (no exit there).
  57.  
  58.      * @param north The north exit.
  59.  
  60.      * @param east The east east.
  61.  
  62.      * @param south The south exit.
  63.  
  64.      * @param west The west exit.
  65.  
  66.      */
  67.  
  68.     public void setExits(Room north, Room east, Room south, Room west)
  69.  
  70.     {
  71.  
  72.         if(north != null)
  73.  
  74.             northExit = north;
  75.  
  76.         if(east != null)
  77.  
  78.             eastExit = east;
  79.  
  80.         if(south != null)
  81.  
  82.             southExit = south;
  83.  
  84.         if(west != null)
  85.  
  86.             westExit = west;
  87.  
  88.     }
  89.  
  90.  
  91.  
  92.     /**
  93.  
  94.      * @return The description of the room.
  95.  
  96.      */
  97.  
  98.     public String getDescription()
  99.  
  100.     {
  101.  
  102.         return description;
  103.  
  104.     }
  105.  
  106.  
  107.  
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement