Question

IN C++ MUST INCLUDE HEADER FILE, IMPLEMENTATION FILE, AND DRIVER FILE. IN C++ Create a header...

IN C++ MUST INCLUDE HEADER FILE, IMPLEMENTATION FILE, AND DRIVER FILE.

IN C++

Create a header and implementation file to define an apartment class. Create a driver program to test the class, and create a make file to compile the driver program.

Create two files called apartment.h and appartmentImp.cpp along with creating 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.

Format your output so that the user of your program understands the values that were input and what was output for each calculation. Your program should have a user-friendly interface. Make sure your program is properly documented and good programming standards are followed.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// Apartment.h

#ifndef ADD_H

#define ADD_H

class Apartment

{

private:

int num_rooms;

double monthly_rent;

double area;

bool washer_dryer_connection;

bool pet_allowed;

public:

Apartment(int a, double b, double c,bool d, bool e);

void setWasherDryerConnection(bool a);

void setPetAllowed(bool a);

void setArea(double a);

int getNumRooms();

double getMonthlyRent();

bool getWasherdryerConnection();

bool getPetAllowed();

double getArea();

bool equal(Apartment a);

void disp();

};

#endif


// Apartment.cpp
#include <iostream>
#include "Apartment.h"

using namespace std;


Apartment::Apartment(int a, double b, double c,bool d, bool e)
{
num_rooms = a;
monthly_rent = b;
area = c;
washer_dryer_connection = d;
pet_allowed = e;
}

void Apartment::setWasherDryerConnection(bool a)
{
washer_dryer_connection = a;
}
void Apartment::setPetAllowed(bool a)
{
pet_allowed = a;
}
void Apartment::setArea(double a)
{
area = a;
}

int Apartment::getNumRooms()
{
return num_rooms;
}

double Apartment::getMonthlyRent()
{
return monthly_rent;
}
bool Apartment::getWasherdryerConnection()
{
return washer_dryer_connection;
}
bool Apartment::getPetAllowed()
{
return pet_allowed;
}
  
double Apartment::getArea()
{
return area;
}

bool Apartment::equal(Apartment a)
{
if (num_rooms == a.getNumRooms() && monthly_rent == a.getMonthlyRent() && washer_dryer_connection == a.getWasherdryerConnection() &&
pet_allowed == a.getPetAllowed())

{
return true;
}
else
{
return false;
}
}


void Apartment::disp()
{
cout << "Number of rooms : " << num_rooms << endl;
cout << "Monthly Rent : $" << monthly_rent << endl;
cout << "Area(Sq feet) : " << area << endl;
if (washer_dryer_connection == false)
cout << "Washer/dryer connection : " << "No" << endl;
else
cout << "Washer/dryer connection : " << "Yes" << endl;
if (pet_allowed == false)
cout << "Pet Allowed : " << "No" << endl;
else
cout << "Pet Allowed : " << "Yes" << endl;

}


//ApartmentImp.cpp
#include <iostream>
#include "Apartment.h"
using namespace std;
int main(){


int num_rooms;
double monthly_rent;
double area;
bool washer_dryer_connection;
bool pet_allowed;

cout << "Enter number of rooms for onCampusApt :";   
cin >> num_rooms;
cout << "Enter monthly rent for onCampusApt :";   
cin >> monthly_rent;
cout << "Enter area for onCampusApt :";   
cin >> area;
cout << "Enter washer/dryer connection for onCampusApt (0-false/1-true) :";   
cin >> washer_dryer_connection;
cout << "Enter pet allowed for onCampusApt(0-false/1-true) :";   
cin >> pet_allowed;
Apartment onCampusApt(num_rooms,monthly_rent, area,washer_dryer_connection,pet_allowed);
cout << "OnCampusApt data is as follows:" << endl;
onCampusApt.disp();
cout<< endl;

cout << "Enter number of rooms for offCampusApt :";   
cin >> num_rooms;
cout << "Enter monthly rent for offCampusApt :";   
cin >> monthly_rent;
cout << "Enter area for offCampusApt :";   
cin >> area;
cout << "Enter washer/dryer connection for offCampusApt (0-false/1-true):";   
cin >> washer_dryer_connection;
cout << "Enter pet allowed for offCampusApt (0-false/1-true):";   
cin >> pet_allowed;
Apartment offCampusApt(num_rooms,monthly_rent, area,washer_dryer_connection,pet_allowed);
cout << "OffCampusApt data is as follows:" << endl;
offCampusApt.disp();

cout<< endl;
if (onCampusApt.equal(offCampusApt)){
cout << "Both are equal" << endl;
}
else {
cout << "Both are not equal" << endl;
}
offCampusApt.setWasherDryerConnection(true);
offCampusApt.setPetAllowed(true);
offCampusApt.setArea(offCampusApt.getArea() + 150);

return 0;
}

Add a comment
Know the answer?
Add Answer to:
IN C++ MUST INCLUDE HEADER FILE, IMPLEMENTATION FILE, AND DRIVER FILE. IN C++ Create a header...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This is done in C++ Create an Employee class using a separate header file and implementation...

    This is done in C++ Create an Employee class using a separate header file and implementation file. Review your UML class diagram for the attributes and behaviors The calculatePay() method should return 0.0f. The toString() method should return the attribute values ("state of the object"). Create an Hourly class using a separate header file and implementation file. The Hourly class needs to inherit from the Employee class The calculatePay() method should return the pay based on the number of hours...

  • C++ must use header files and implementation files as separate files. I’ll need a header file,...

    C++ must use header files and implementation files as separate files. I’ll need a header file, implementation file and the main program file at a minimum. Compress these files into one compressed file. Make sure you have adequate documentation. We like to manipulate some matrix operations. Design and implement a class named matrixMagic that can store a matrix of any size. 1. Overload the addition, subtraction, and multiplication operations. 2. Overload the extraction (>>) and insertion (<<) operators to read...

  • Please write a c++ header file, class implementation file and main file that does all of...

    Please write a c++ header file, class implementation file and main file that does all of the following and meets the requirements listed below. Also include a Output of your code as to show that your program works and functions properly. EXERCISING A DOUBLY-LINKED LIST CLASS This project consists of two parts, the second of which appears below. For the first part, write a class that implements an unordered list abstract data type using a doubly-linked list with pointers to...

  • I am working in c++. My program requires me to use a header file that is...

    I am working in c++. My program requires me to use a header file that is provided. I must use this header file and create 5 methods: 2 constructors, 2 accessors and this operation* on a 4x4 matrix. Matrix has 16 floating point values that must be entered by user. The Two operator functions: i*t; and t+i, multiply identity (i) matrix by user input value matrix and second function add identity (i) plus user input matrix transform. These two operations...

  • I need a c++ visual basic program that will. Carpet Calculator. This problem starts with the...

    I need a c++ visual basic program that will. Carpet Calculator. This problem starts with the FeetInches class that is provided in the course Content area on the assignment page for this week. This program will show how classes will interact with each other as data members within another class. Modify the FeetInches class by overloading the following operators which should all return a bool. <= >= != Next add a copy constructor to the FeetInches class and a multiply...

  • C++ project we need to create a class for Book and Warehouse using Book.h and Warehouse.h header ...

    C++ project we need to create a class for Book and Warehouse using Book.h and Warehouse.h header files given. Then make a main program using Book and Warehouse to read data from book.dat and have functions to list and find book by isbn Objectives: Class Association and operator overloading This project is a continuation from Project 1. The program should accept the same input data file and support the same list and find operations. You will change the implementation of...

  • In header file (.h) and c++ file format (.cpp). A local company has asked you to...

    In header file (.h) and c++ file format (.cpp). A local company has asked you to write a program which creates an Employee class, a vector of Employee class objects, and fills the objects with employee data, creating a "database" of employee information. The program allows the user to repeatedly search for an employee in the vector by entering the employee's ID number and if found, display the employee's data. The Employee_C class should have the following data and in...

  • .Your solution must include header, implementation file, and test files .In C++ write a code to...

    .Your solution must include header, implementation file, and test files .In C++ write a code to Consider a graphics system that has classes for various figures rectangles, squares, triangles, circles, and so on. For example, a rectangle might have data members for Height, Width and center point, while a square and circle might have only a center point and an edge length or radius. In a well-designed system, these would be derived from a common class, Figure. You are to...

  • C++ Create an array-based implementation of a stack. Each element of the stack should store a...

    C++ Create an array-based implementation of a stack. Each element of the stack should store a string. The stack class should include 3 private member variables (maximum stack size, top of the stack index, and a pointer to the array that holds the stack elements). Public member methods should include a constructor (with an argument of stack maximum size that is used to create a dynamic array), a destructor (that deletes the dynamic array), a push method (argument is a...

  • c++ driver and car are independed classes 1. Create a class Car, which has a color, engine, horsepower, fuel, FuelLevel, year of manufacturing and driver which can be defined by name, age, licen...

    c++ driver and car are independed classes 1. Create a class Car, which has a color, engine, horsepower, fuel, FuelLevel, year of manufacturing and driver which can be defined by name, age, licenseNumber. Create the corresponding OOP in For each class (Driver, Car) write a header file and the class implementation -In the main function do the following: from that class in main function. L.1 Write a function that will print the total number of objects created 12 Define an...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT