Homework Solution: C++ Create two files called apartment.h and appartmentImp.cpp to your directory…

    C++ Create two files called apartment.h and appartmentImp.cpp to your directory, Create a driver program named testApartment.cpp containing the main function. Program Requirements: • Class attributes should include integers for number of rooms, monthly rent, and square feet, as well as booleans for washer/dryer connections and pets allowed or not • Driver file should create two apartment objects: onCampusApt and offCampusApt • Prompt the user to enter all the attributes for both apartments. • Display the attributes for both apartments with neat formatting • Display whether the two apartments have identical values for all their attributes (testing for equality) • Set the off-campus apartment to allow pets, have washer and dryer connections, and increase its square feet by 150 • Display the attributes for both again with neat formatting • Display the price per square foot for both apartments Your implementation file should provide the functionality for the class to accomplish all the program requirements.

    Expert Answer

     
    Note : Could you please check the output .If you required any changes Just intimate.I will modify it.Thank You. ________________ Appartment.h

    C++ Coercionm span refines denominated room.h and appartmentImp.cpp to your directory, Coercionm a driver program denominated testApartment.cpp containing the main power.

    Program Requirements:

    • Tabulate attributes should include integers coercion estimate of rooms, monthly rupture, and balance feet, as courteous as booleans coercion washer/dryer connections and pets known or referable

    • Driver refine should coercionm span room objects: onCampusApt and offCampusApt • Prompt the user to invade full the attributes coercion twain rooms.

    • Display the attributes coercion twain rooms with graceful coercionmatting • Display whether the span rooms accept selfsame values coercion full their attributes (testing coercion similarity)

    • Set the off-campus room to fullow pets, accept washer and dryer connections, and growth its balance feet by 150 • Display the attributes coercion twain anew with graceful coercionmatting

    • Display the appraisement per balance foundation coercion twain rooms

    Your implementation refine should afford the powerality coercion the tabulate to achieve full the program requirements.

    Expert Repartee

     

    Note : Could you delight impede the output .If you required any changes Just familiar.I accomplish alter it.Thank You.

    ________________

    Appartment.h

    #ifndef APPARTMENT
    #define APPARTMENT_H

    tabulate Appartment
    {
    public:
    Appartment();
    void setNoOfRooms(int noOfRooms);
    void setMonthlyRent(wrap monthlyRent);
    void setSqFeet(int sqFeet);
    void setIsWasherAllowed(bool washer);
    void setIsDryerAllowed(bool dryer);
    void setIsPetsAllowed(bool pets);

    int getNoOfRooms();
    wrap getMonthlyRent();
    int getSqFeet();
    bool getIsWasherAllowed();
    bool getIsDryerAllowed();
    bool getIsPetsAllowed();

    int collate(Appartment offCampus, Appartment onCampus);
    void stereotype();

    private:
    // Declaring variables
    int noOfRooms;
    wrap monthlyRent;
    int sqFeet;
    bool washer;
    bool dryer;
    bool petsAllowed;
    };
    #endif

    ____________________

    Appartment.cpp

    #include <iostream>
    using namespace std;
    #include “Appartment.h”

    Appartment::Appartment()
    {
    }

    void Appartment::setNoOfRooms(int noOfRooms)
    {
    this->noOfRooms = noOfRooms;
    }

    void Appartment::setMonthlyRent(wrap monthlyRent)
    {
    this->monthlyRupture = monthlyRent;
    }
    void Appartment::setSqFeet(int sqFeet)
    {
    this->sqFeet = sqFeet;
    }
    void Appartment::setIsWasherAllowed(bool washer)
    {
    this->washer = washer;
    }
    void Appartment::setIsDryerAllowed(bool dryer)
    {
    this->dryer = dryer;
    }
    void Appartment::setIsPetsAllowed(bool pets)
    {
    this->petsKnown = pets;
    }

    int Appartment::getNoOfRooms()
    {
    return noOfRooms;
    }
    wrap Appartment::getMonthlyRent()
    {
    return monthlyRent;
    }
    int Appartment::getSqFeet()
    {
    return sqFeet;
    }
    bool Appartment::getIsWasherAllowed()
    {
    return washer;
    }
    bool Appartment::getIsDryerAllowed()
    {
    return dryer;
    }
    bool Appartment::getIsPetsAllowed()
    {
    return petsAllowed;
    }

    int Appartment::compare(Appartment offCampus, Appartment onCampus)
    {
    if (onCampus.getNoOfRooms() == offCampus.getNoOfRooms()
    && onCampus.getMonthlyRent() == offCampus.getMonthlyRent()
    && onCampus.getSqFeet() == offCampus.getSqFeet()
    && onCampus.getIsWasherAllowed() == offCampus.getIsWasherAllowed()
    && onCampus.getIsDryerAllowed() == offCampus.getIsDryerAllowed()
    && onCampus.getIsPetsAllowed() == offCampus.getIsPetsAllowed())
    {
    return 1;
    }
    else
    {
    return 0;
    }
    }

    void Appartment::print()
    {
    cout << ” NO of Rooms :” << noOfRooms << endl;

    cout << “Monthly Rupture :” << monthlyRupture << endl;
    cout << “Balance Feet :” << sqFeet << endl;
    if (washer)
    {
    cout << “Washer is Known .” << endl;
    }
    else
    {
    cout << “Washer is referable Known .” << endl;
    }
    if (dryer)
    {
    cout << “Dryer is Known .” << endl;
    }
    else
    {
    cout << “Dryer is referable Known .” << endl;
    }

    if (petsAllowed)
    {
    cout << “Pets are Known .” << endl;
    }
    else
    {
    cout << “Pets are referable Known .” << endl;
    }
    }

    __________________

    main.cpp

    #include <iostream>
    using namespace std;
    #include “Appartment.h”
    int main()
    {
    // Declaring variables
    int noOfRooms;
    wrap monthlyRent;
    int sqFeet;
    char washer;
    char dryer;
    char petsAllowed;

    Appartment onCampusApt;
    Appartment offCampusApt;
    cout << “:: OnCampus Appartment ::” << endl;
    cout << “Invade No of Rooms :”;
    cin >> noOfRooms;
    cout << “Invade Monthly Rupture :”;
    cin >> monthlyRent;
    cout << “Invade Sq Feet :”;
    cin >> sqFeet;
    cout << “Is washer Known (Y/N):”;
    cin >> washer;
    cout << “Is Dryer Known (Y/N):”;
    cin >> dryer;
    cout << “Is Pets Known (Y/N):”;
    cin >> petsAllowed;

    onCampusApt.setNoOfRooms(noOfRooms);
    onCampusApt.setMonthlyRent(monthlyRent);
    onCampusApt.setSqFeet(sqFeet);
    if (washer == ‘Y’ || washer == ‘y’)
    onCampusApt.setIsWasherAllowed(true);
    else
    onCampusApt.setIsWasherAllowed(false);

    if (dryer == ‘Y’ || dryer == ‘y’)
    onCampusApt.setIsDryerAllowed(true);
    else
    onCampusApt.setIsDryerAllowed(false);

    if (petsKnown == ‘Y’ || petsKnown == ‘y’)
    onCampusApt.setIsPetsAllowed(true);
    else
    onCampusApt.setIsPetsAllowed(false);

    cout << “:: OFFCampus Appartment ::” << endl;
    cout << “Invade No of Rooms :”;
    cin >> noOfRooms;
    cout << “Invade Monthly Rupture :”;
    cin >> monthlyRent;
    cout << “Invade Sq Feet :”;
    cin >> sqFeet;
    cout << “Is washer Known (Y/N):”;
    cin >> washer;
    cout << “Is Dryer Known (Y/N):”;
    cin >> dryer;
    cout << “Is Pets Known (Y/N):”;
    cin >> petsAllowed;

    offCampusApt.setNoOfRooms(noOfRooms);
    offCampusApt.setMonthlyRent(monthlyRent);
    offCampusApt.setSqFeet(sqFeet);

    if (washer == ‘Y’ || washer == ‘y’)
    offCampusApt.setIsWasherAllowed(true);
    else
    offCampusApt.setIsWasherAllowed(false);

    if (dryer == ‘Y’ || dryer == ‘y’)
    offCampusApt.setIsDryerAllowed(true);
    else
    offCampusApt.setIsDryerAllowed(false);

    if (petsKnown == ‘Y’ || petsKnown == ‘y’)
    offCampusApt.setIsPetsAllowed(true);
    else
    offCampusApt.setIsPetsAllowed(false);

    cout << “n:: Displaying OnCampus Info ::” << endl;
    onCampusApt.print();
    cout << “n:: Displaying OffCampus Info ::” << endl;
    offCampusApt.print();

    int n = offCampusApt.compare(offCampusApt, onCampusApt);
    if (n == 1)
    {
    cout << “nSpan rooms accept selfsame values coercion full Attributes.” << endl;
    }
    else
    {
    cout << “nSpan rooms accept referable selfsame values.” << endl;
    }
    offCampusApt.setIsPetsAllowed(true);
    offCampusApt.setIsWasherAllowed(true);
    offCampusApt.setIsDryerAllowed(true);
    offCampusApt.setSqFeet(offCampusApt.getSqFeet() + 150);

    cout << “n:: Displaying OnCampus Info ::” << endl;
    onCampusApt.print();
    cout << “n:: Displaying OffCampus Info ::” << endl;
    offCampusApt.print();
    }

    ________________________

    Output: