// Calculate the area required for painting a room and the cost
// Language used C++
/*
Room is an object whose data members are the 4 walls and the ceiling
All the 4 walls are themselves an object with data members being their length and breadth
*/
#include <iostream>
using namespace std;
class Wall
{
private:
float length ;
float breadth ;
public:
void getWallDimensions()
{
if (length ==0 || breadth ==0)
{
cout << " The dimensions have not been set ";
}
else
{
cout << " The length of the wall is" << length << endl;
}
}
void setWallDimensions()
{
cout << " Enter the length of the wall" << endl;
cin >> length;
cout << " Enter the breadth of the wall" << endl;
cin >> breadth;
}
float getWallArea()
{
float wall_area;
wall_area = length * breadth;
return wall_area;
}
};
class Room
{
private:
Wall f_w; //First Wall object
Wall s_w; //Second wall object
Wall t_w; //Third wall object
Wall ft_w; //Fourth wall object
Wall c; //Ceiling object
float room_area;
public:
void setRoomDimensions() // Sets the length and breadth for all the walls and ceiling of the room
{
cout << " Enter the dimensions for the first wall" << endl;
f_w.setWallDimensions();
cout << " Enter the dimensions for the second wall" << endl;
s_w.setWallDimensions();
cout << " Enter the dimensions for the third wall" << endl;
t_w.setWallDimensions();
cout << " Enter the dimensions for the fourth wall" << endl;
f_w.setWallDimensions();
cout << " Enter the dimensions for the ceiling" << endl;
c.setWallDimensions();
}
void getRoomArea()
{
room_area = f_w.getWallArea() + s_w.getWallArea() + t_w.getWallArea() + ft_w.getWallArea() + c.getWallArea();
cout << " The total area of the room is : " << room_area;
}
};
int main ()
{
Room bedroom;
bedroom.setRoomDimensions();
bedroom.getRoomArea();
return 0;
}