HouseDriver.txt is called from Main.
The sentence makes little sense. Could it be that there is a file called HouseDriver.txt that is read into main?
What do the numbers mean and how are they distributed in the classes house and room? Conceptually, a class should contain all the associated data and methods to access it.
You describe here how you try to implement the method getNumBedrooms().
If you assume that a house should contain rooms it makes little sense to create single rooms in one method. It can't work like this:
int House::getNumBedrooms()
{
int numbed;
Room r;
numbed = r.getSquareFootage();
return numbed;
}
So far, you've only told us that your House class looks like this:
class House
{
public:
int getNumBedrooms() {};
};
One would expect a house to contain rooms. Where are they here?
Here, a std container such as a vector with rooms, which is located in the class House, would be advisable. Of course you need methods to fill the house with rooms. All in all the following approach would be possible:
class House
{
public:
int getNumBedrooms();
bool addRoom(const Room& room);
private:
vector<class Room> roomlst;
};
// edit:
The method getNumBedrooms() should probably get the number of rooms of this type. You have now indicated that the data type RoomType is also present.
It actually makes little sense to write a separate method for each room type, since the process is always the same. The list with rooms must be searched and rooms of the desired type are counted. It would make sense to first write a method that counts all rooms of a type. If desired, these could then be called in separate methods without parameters.
int House::getNumBathrooms() {
return getNumRoomType(BATHROOM);
}
int House::getNumRoomType(RoomType type)
{
int cnt = 0;
for (auto&& n : roomlst) {
}
return cnt;
}