Answer to Question #111720 in C++ for ploi

Question #111720
Starting with the following class as an example on using vectors:

class House{

private:
vector <Room> rooms;
public:
void AddRoom (Room r) {

rooms.push_back(r);
}

void PrintRooms (){

for (int i = 0; i < rooms.size(); i++ ){

cout << rooms.at(i).GetName(); // assumes room has a getter GetName()
}

}
};

Develop this example as follows:

• Create Room class with name and area as private members and appropriate setters/getters

• Modify PrintRooms in House class to print room names and areas.

• Complete the House class by adding a function that calculates the house area (sum of room areas)

• Add a function RemoveRoom to remove a room with given name (research erase function which is a member of vector)

• In main:

• Create a house, add some rooms, print rooms’ names and areas, print total house area

• Remove a room

• Print rooms’ names and areas as well as house’s area after removing the room
1
Expert's answer
2020-04-23T00:28:47-0400
Dear ploi, your question requires a lot of work, which neither of our experts is ready to perform for free. We advise you to convert it to a fully qualified order and we will try to help you. Please click the link below to proceed: Submit order

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS