Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Room
- {
- // instance variables - replace the example below with your own
- private String number;
- private String name;
- private int capacity;
- private char setUp;
- private boolean isReconfigurable;
- private String configureOptions;
- private Room canBeCombinedWith = null;
- private static int numberofRooms = 0;
- private static int totalCapacity = 0;
- /**
- * Constructor for objects of class Room
- */
- public Room(String number, String name, int capacity, char setUp, boolean isReconfigurable, String configureOptions)
- {
- // initialise instance variables
- this.number = number;
- this.name = name;
- this.capacity = capacity;
- this.setUp = setUp;
- this.isReconfigurable = isReconfigurable;
- this.configureOptions = configureOptions;
- }
- public void updateCanBeCombinedWith(Room r)
- {
- r = canBeCombinedWith;
- }
- public int getRoomCapacity(){
- return capacity;
- }
- public void reconfigure(char option){
- while(isReconfigurable = true){
- if(option == charAt(i)){
- configureOptions = configureOptions + option;
- }
- }
- }
- public boolean isCompatibleWith(Room other){
- if(this.capacity == other.getRoomCapacity() && this.configureOptions == configureOptions){
- return true;
- }
- else{
- return false;
- }
- }
- public String toString(){
- String s = "";
- String st = "";
- s = "Room number:\t" + this.number + "\n";
- if(!(this.name.isEmpty())){
- s = s + "name:\t" + this.name;
- }
- s = s + "capacity:\t" + this.capacity + "\n";
- if(this.setUp == ('T')){
- st = "Theatre style";
- }
- else if(this.setUp == ('C')){
- st = "Classroom";
- }
- else if(this.setUp == ('U')){
- st = "U-shape";
- }
- else if(this.setUp == ('B')){
- st = "Banquet";
- }
- else if(this.setUp == ('E')){
- st = "Boardroom";
- }
- s = s + "setUp:\t" + st + "\n";
- if(isReconfigurable){
- s = s + "reconfigure options:\t" + this.configureOptions + "\n";
- }
- if(isCompatibleWith(Room r)){
- s = s + "can be combined with room # " + number;
- }
- }
- public static int getNumberofRooms(){
- return numberOfRooms;
- }
- public static int getTotalCapacity(){
- return totalCapacity;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement