Advertisement
Guest User

vtora od 3ti

a guest
Mar 28th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.53 KB | None | 0 0
  1. // your code here
  2. #include <iostream>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6. class Table{
  7.     private:
  8.     int width;
  9.     int height;
  10.     public:
  11.     Table()
  12.     {
  13.         width = 0;
  14.         height = 0;
  15.     }
  16.     Table (int width, int height)
  17.     {
  18.         this->width=width;
  19.         this->height=height;
  20.     }
  21.     ~Table(){};
  22.     void print()
  23.     {
  24.         cout<< "Table: " << width << " " << height;
  25.     }
  26. };
  27.  
  28. class Room{
  29.     private:
  30.     Table t;
  31.     int length;
  32.     int width;
  33.     public:
  34.     Room (){}
  35.     Room (int width, int length, Table t)
  36.     {
  37.         this->width = width;
  38.         this->length = length;
  39.         this->t = t;
  40.     }
  41.     void print()
  42.     {
  43.         cout<< "Room: " << width << " " << length << " ";
  44.         t.print();
  45.     }
  46. };
  47.  
  48. class House {
  49.     private:
  50.     char address[50];
  51.     Room r;
  52.     public:
  53.     House (Room r, char *address)
  54.     {
  55.         this->r = r;
  56.         strcpy(this->address, address);
  57.     }
  58.     void print()
  59.     {
  60.         //Address: Goce_Delcev_20 Room: 10 20 Table: 2 4
  61.         cout << "Address: " << address << " ";
  62.         r.print();
  63.         cout << " " << endl;
  64.     }
  65. };
  66. int main(){
  67.     int n;
  68.     cin>>n;
  69.     for(int i=0;i<n;i++){
  70.         int tableWidth, tableHeight;
  71.         cin>>tableWidth;
  72.         cin>>tableHeight;
  73.         Table t(tableWidth, tableHeight);
  74.         int rw, rl;
  75.         cin>>rw;
  76.         cin>>rl;
  77.         Room r(rw, rl, t);
  78.         char adresa[30];
  79.         cin>>adresa;
  80.         House h(r,adresa);
  81.         h.print();
  82.     }
  83.    
  84.     return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement