Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. public class Room
  2. {
  3. // instance variables - replace the example below with your own
  4. private String number;
  5. private String name;
  6. private int capacity;
  7. private char setUp;
  8. private boolean isReconfigurable;
  9. private String configureOptions;
  10. private Room canBeCombinedWith = null;
  11. private static int numberofRooms = 0;
  12. private static int totalCapacity = 0;
  13.  
  14. /**
  15. * Constructor for objects of class Room
  16. */
  17. public Room(String number, String name, int capacity, char setUp, boolean isReconfigurable, String configureOptions)
  18. {
  19. // initialise instance variables
  20. this.number = number;
  21. this.name = name;
  22. this.capacity = capacity;
  23. this.setUp = setUp;
  24. this.isReconfigurable = isReconfigurable;
  25. this.configureOptions = configureOptions;
  26. }
  27.  
  28. public void updateCanBeCombinedWith(Room r)
  29. {
  30. r = canBeCombinedWith;
  31. }
  32. public int getRoomCapacity(){
  33. return capacity;
  34. }
  35. public void reconfigure(char option){
  36. while(isReconfigurable = true){
  37. if(option == charAt(i)){
  38. configureOptions = configureOptions + option;
  39. }
  40. }
  41. }
  42. public boolean isCompatibleWith(Room other){
  43. if(this.capacity == other.getRoomCapacity() && this.configureOptions == configureOptions){
  44. return true;
  45. }
  46. else{
  47. return false;
  48. }
  49. }
  50. public String toString(){
  51. String s = "";
  52. String st = "";
  53. s = "Room number:\t" + this.number + "\n";
  54. if(!(this.name.isEmpty())){
  55. s = s + "name:\t" + this.name;
  56. }
  57. s = s + "capacity:\t" + this.capacity + "\n";
  58. if(this.setUp == ('T')){
  59. st = "Theatre style";
  60. }
  61. else if(this.setUp == ('C')){
  62. st = "Classroom";
  63. }
  64. else if(this.setUp == ('U')){
  65. st = "U-shape";
  66. }
  67. else if(this.setUp == ('B')){
  68. st = "Banquet";
  69. }
  70. else if(this.setUp == ('E')){
  71. st = "Boardroom";
  72. }
  73. s = s + "setUp:\t" + st + "\n";
  74. if(isReconfigurable){
  75. s = s + "reconfigure options:\t" + this.configureOptions + "\n";
  76. }
  77. if(isCompatibleWith(Room r)){
  78. s = s + "can be combined with room # " + number;
  79. }
  80. }
  81. public static int getNumberofRooms(){
  82. return numberOfRooms;
  83. }
  84. public static int getTotalCapacity(){
  85. return totalCapacity;
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement