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, ApartmentBuild

ID: 3535322 • 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
{
public:
    ApartmentBuilding(int,int,bool,bool);
    int getTotalUnits();
    bool isLuxuryBuilding();

private:
    int numFloors;
    int unitsPerFloor;
    bool hasElevator;
    bool hasCentralAir;
};

ApartmentBuilding::ApartmentBuilding(int a, int b,bool c,bool d)
{
    numFloors = a;
    unitsPerFloor = b;
    hasElevator = c;
    hasCentralAir = d;
}
int ApartmentBuilding::getTotalUnits()
{
    return numFloors * unitsPerFloor;
}
bool ApartmentBuilding::isLuxuryBuilding()
{
    if (hasCentralAir && hasElevator && unitsPerFloor <= 2)
    {
        return true;
    }
    else
    {
        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