Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This lab will test your ability to perform deep and shallow copies, overload operators, friendship, and use the copy constructor and assignment as well as

This lab will test your ability to perform deep and shallow copies, overload operators, friendship, and use the copy constructor and assignment as well as the move constructor and assignment.

This program creates objects of type House. Each house has an owner, address, rooms, bathrooms, and a price. The class functions that operate on this data are as follows:

House();//Default constructor

House(const char* _owner, const char* _address, const double _rooms, const double _bathrooms, const double _price);//Data for the house object

House(const House& house);//Copy constructor

House& operator=(const House& house);//Copy assignment

House(House&& house) noexcept;//Move constructor

House& operator=(House&& house) noexcept;//Move assignment

bool ChangeOwner(char* newOwner);//Change the owner. Test to see if the character array newOwner actually exists. If it doesn't, return false, otherwise return true.

bool ChangePrice(double newPrice);//Change the price. Test to see if the price is a positive number. If it isn't, return false, otherwise return true.

const House& operator+=(double amount);//increase/decrease the price of the house

void DisplayInfo() const;//Display the owner, address, rooms, bathrooms, and price. All double's should be printed to two decimal places.

~House();//Destructor

There are also two functions that operate on this data from outside the class. They are as follows:

bool operator==(const House& house1, const House& house2);//Do the two houses have the same owner?

void operator>>(House& house1, House& house2);//Move contents from the house1 object to the house2 object

Note that operator== might require access to private members of the House object, so you may have to modify House.h. Also, you might decide that operator== and operator>> can be implemented within the class. You are free to move them to within the class if you wish.

You have been given a header file for House and a main file for testing: House.h and HouseMain.cpp. Complete House.cpp.

A sample run is as follows:

 Owner: Lionel Messi Address: 34 Cedarwood Road Rooms: 5.00 Bathrooms: 2.50 Price: $2500000.00 Owner: Neymar da Silva Santos Junior Address: 12 Broadway Street Rooms: 7.00 Bathrooms: 4.00 Price: $5600000.00 Owner: Lionel Messi Address: 34 Cedarwood Road Rooms: 5.00 Bathrooms: 2.50 Price: $2500000.00 Owner: Neymar da Silva Santos Junior Address: 12 Broadway Street Rooms: 7.00 Bathrooms: 4.00 Price: $5600000.00 ---------------------------- Owner: none Address: none Rooms: 0.00 Bathrooms: 0.00 Price: $0.00 Owner: none Address: none Rooms: 0.00 Bathrooms: 0.00 Price: $0.00 Owner: Lionel Messi Address: 34 Cedarwood Road Rooms: 5.00 Bathrooms: 2.50 Price: $2500000.00 Owner: Neymar da Silva Santos Junior Address: 12 Broadway Street Rooms: 7.00 Bathrooms: 4.00 Price: $5600000.00 Owner: Lionel Messi Address: 34 Cedarwood Road Rooms: 5.00 Bathrooms: 2.50 Price: $2500000.00 Owner: Neymar da Silva Santos Junior Address: 12 Broadway Street Rooms: 7.00 Bathrooms: 4.00 Price: $5600000.00 ---------------------------- Houses 3 and 5 are the same Houses 4 and 6 are the same ---------------------------- Owner: Lionel Messi Address: 34 Cedarwood Road Rooms: 5.00 Bathrooms: 2.50 Price: $3500000.00 Owner: Neymar da Silva Santos Junior Address: 12 Broadway Street Rooms: 7.00 Bathrooms: 4.00 Price: $6600000.00 Owner: Lionel Messi Address: 34 Cedarwood Road Rooms: 5.00 Bathrooms: 2.50 Price: $2500000.00 Owner: Neymar da Silva Santos Junior Address: 12 Broadway Street Rooms: 7.00 Bathrooms: 4.00 Price: $5600000.00 ---------------------------- Owner: none Address: none Rooms: 0.00 Bathrooms: 0.00 Price: $0.00 Owner: none Address: none Rooms: 0.00 Bathrooms: 0.00 Price: $0.00 Owner: Lionel Messi Address: 34 Cedarwood Road Rooms: 5.00 Bathrooms: 2.50 Price: $3500000.00 Owner: Neymar da Silva Santos Junior Address: 12 Broadway Street Rooms: 7.00 Bathrooms: 4.00 Price: $6600000.00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

Define and explain the nature of nonassociative learning.

Answered: 1 week ago

Question

=+10. What is the brand's character or personality?

Answered: 1 week ago