Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assume the existence of a Building class . Define a derived class , ApartmentBui

ID: 3545400 • Letter: A

Question

Assume  the existence of a Building class . Define a derived class , ApartmentBuilding that contains four (4) data members: an integer  named  numFloors, an integer  named  unitsPerFloor, a boolean  named  hasElevator, and a boolean  named  hasCentralAir.

There is a constructor  containing parameters  for the initialization  of the above variables  (in the same order as they appear above).

There are also two function: the first, getTotalUnits, accepts no parameters  and returns the total number of units in the building; the second, isLuxuryBuilding accepts no parameters  and returns true  if the building has central air, an elevator and 2 or less units per floor.

Explanation / Answer

class ApartmentBuilding: public Building
{
private:
int numFloors;
int unitsPerFloor;
bool hasElevator;
bool hasCentralAir;
public:
ApartmentBuilding(int x, int y, bool a, bool b)
{
numFloors = x;
unitsPerFloor = y;
hasElevator = a;
hasElevator = b;
}
int getTotalUnits()
{
return numFloors * unitsPerFloor;
}
bool isLuxuryBuilding()
{
if(hasCentralAir && hasElevator && unitsPerFloor <= 2)
{
return true;
}
return false;
}
};

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote