Answer:
Step-by-step explanation:
The following code is written in Java. The class ApartmentBuilding extends the assumed class of Building but does not call any of its methods since we do not have access to it. The ApartmentBuilding class contains all of the variables listed, as well as constructor and methods, including getter and setter methods for each variable. A test case for the class is provided in the image below with it's output.
class ApartmentBuilding extends Building {
int numFloors, unitsPerFloor;
boolean hasElevator, hasCentralAir;
public ApartmentBuilding(int numFloors, int unitsPerFloor, boolean hasElevator, boolean hasCentralAir) {
this.numFloors = numFloors;
this.unitsPerFloor = unitsPerFloor;
this.hasElevator = hasElevator;
this.hasCentralAir = hasCentralAir;
}
public int getTotalUnits() {
int total = this.numFloors * this.unitsPerFloor;
return total;
}
public boolean isLuxuryBuilding() {
if ((this.hasCentralAir == true) && (this.hasElevator == true) && (this.unitsPerFloor <= 2)) {
return true;
} else {
return false;
}
}
public int getNumFloors() {
return numFloors;
}
public void setNumFloors(int numFloors) {
this.numFloors = numFloors;
}
public int getUnitsPerFloor() {
return unitsPerFloor;
}
public void setUnitsPerFloor(int unitsPerFloor) {
this.unitsPerFloor = unitsPerFloor;
}
public boolean isHasElevator() {
return hasElevator;
}
public void setHasElevator(boolean hasElevator) {
this.hasElevator = hasElevator;
}
public boolean isHasCentralAir() {
return hasCentralAir;
}
public void setHasCentralAir(boolean hasCentralAir) {
this.hasCentralAir = hasCentralAir;
}
}