ComputerLab
-numberWorkingComputer:int
+<>ComputerLab()
++<>ComputerLab(int,String,String,int)
+setNumberWorkingComputers(int):void
+getNumberWorkingComputer():int
+toString():String
+show():void
+problemVenue():boolean
Code the attributes and methods as per diagram for the ComputerLab class. 1 Remember to call the superclass constructors in the coding of the ComputerLab constructors. 2 Remember to call the superclass toString() in the ComputerLab toString(). 3 Code the show() method. This method is void and displays the details of a ComputerLab object. Again, remember to call the show() of the superclass. Building name: Engineering, Venue number: 1.24, Number of seats: 40, Number of working computers: 35 4, Code the method problemVenue. This method returns a boolean value of true if the numberSeats in the computer lab is more than the numberWorkingComputers, else a boolean value of false is returned.
public class ComputerLab extends Building {
private int numberWorkingComputer;
public ComputerLab() {
super("Unknown", "0", 0);
numberWorkingComputer = 0;
}
public ComputerLab(int numberWorkingComputer, String buildingName, String venueNumber, int numberOfSeats) {
super(buildingName, venueNumber, numberOfSeats);
this.numberWorkingComputer = numberWorkingComputer;
}
public void setNumberWorkingComputer(int numberWorkingComputer) {
this.numberWorkingComputer = numberWorkingComputer;
}
public int getNumberWorkingComputer() {
return numberWorkingComputer;
}
public void show() {
super.show();
System.out.println(", Number of working computers: " + numberWorkingComputer);
}
public boolean problemVenue() {
return getNumberOfSeats() > numberWorkingComputer;
}
@Override
public String toString() {
return super.toString() + ", Number of working computers: " + numberWorkingComputer;
}
}
Comments
Leave a comment