Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. package ss.week2.hotel;
  2.  
  3. /**
  4. * Hotel room with number and possibly a guest.
  5. * @author Arend Rensink
  6. * @version $Revision: 1.2 $
  7. */
  8. public class Room {
  9. // ------------------ Instance variables ----------------
  10.  
  11. private int number;
  12. private Guest guest;
  13. private Safe safe;
  14.  
  15. // ------------------ Constructor ------------------------
  16.  
  17. /**
  18. * Creates a <code>Room</code> with the given number, without a guest.
  19. * @param no number of the new <code>Room</code>
  20. */
  21. public Room(int no) {
  22. number = no;
  23. safe = new Safe("123456789");
  24. }
  25.  
  26. public String toString(){
  27. return "Room " + number;
  28. }
  29.  
  30.  
  31. // ------------------ Queries --------------------------
  32.  
  33. /**
  34. * Returns the number of this <code>Room</code>.
  35. */
  36. public int getNumber() {
  37. return number;
  38. }
  39.  
  40. /**
  41. * Returns the current guest living in this <code>Room</code>.
  42. * @return the guest of this <code>Room</code>;
  43. * <code>null</code> if this <code>Room</code>
  44. * is not currently rented
  45. */
  46. public Guest getGuest() {
  47. return guest;
  48. }
  49.  
  50. public Safe getSafe(){
  51. return safe;
  52. }
  53.  
  54. // ------------------ Commands --------------------------
  55.  
  56. /**
  57. * Assigns a <code>Guest</code> to this <code>Room</code>.
  58. * @param g the next guest renting this <code>Room</code>;
  59. * if <code>null</code> is passed, this <code>Room</code>
  60. * is empty afterwards
  61. */
  62. public void setGuest(Guest g) {
  63. guest = g;
  64. }
  65.  
  66. // @Override
  67. //public String toString() {
  68. // return "Room [number=" + number + ", guest=" + guest + ", "
  69. // + "getNumber()=" + getNumber() + ", getGuest()=" + getGuest() + "]";
  70. //}
  71.  
  72.  
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement