language: C++ 4.7.2 (gcc-4.7.2)
date: 188 days 3 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#include<iostream>
#include<string>
using namespace std;
 
class House{
private:
    string *nameowner;
    int *numroom;
        int *Rentingfee;
        Room *room;
        friend class Town;
public:
House(){
        setnameowner();
                setnumroom();
                Rentingfee=new int(0);}
                
        
        ~House(){
                cout<<"bye House"<<endl;
                delete []room;
        }
 
 
        void setnameowner(){
           string a;
           cout<<"enter the owner name of this house:";
           cin>>a;
           nameowner=new string(a);}
 
         const string *getnameowner() const{
                 return nameowner;}
 
        void setnumroom(){
                int b;
                cout<<"Enter the rooms number of this house:";
                cin>>b;
                numroom=new int(b);
                setRoom(b);
        }
 
        const int *getnumroom()const{
                return numroom;}
 
 
        void setRoom(int n){
                room=new Room[n];}
 
        void setRentingFee(int index){
                int m;
                cout<<"Enter the monthly Renting fee of this house:";
                cin>>m;
                Rentingfee=new int(m);
        }
 
        const int *getRentingFee()const{
                return Rentingfee;
        }
 
        void DisplayHouse(){
                cout<<"the house name is :"<<getnameowner()<<endl;
                cout<<"the Renting fee is : "<<getRentingFee()<<endl;
                cout<<"the number of rooms in this house is :"<<getnumroom()<<endl;
                cout<<"and the rooms details as follows:"<<endl;
                for(int i=0;i<*numroom;i++)
                        room[i].DisplayRoom();}
};      
 
class Town{
private:
    House *homes;
        bool *Rented;
        string *NameTown;
        static  int Num;
 
public:
        Town(string n ){
    setnametown(n);
    Rented= new bool [5];
        for ( int i=0;i<5;i++){
                Rented [i]=0;
                sethomes();
                Num++;} // end constructor
 
       ~Town();
        cout<<"bye Town"<<endl;
                delete []homes ;
                homes=0;} // end destructor
 
        void setnametown( string n ){
                cout<<"Enter the name of this Town ::";
                        cin>>n;
                        NameTown=new string(n);}
 
 
 
    const string *getNameTown() const{
                return NameTown;}
 
         int getNum(){
                 return Num;}
 
        void sethomes(){
                 homes=new House[5];}
 
 
        void Addhouse(House a ,int index){
                homes[index]=a;
setRented(index);
if( Rented[index]=1)
        homes[index]. setRentingFee(index);
else
        cout<<"No Rening fee"<<endl;}
 
 
        void setRented(int index){
                IsRented( index);}
      
        void IsRented(int index){
                bool a;
                cout<<"Is this house with index"<<index<<"rented?? "<<endl;
                        cout<<"if yes enter 1 else enter 0"<<endl;
       cin>>a;
           if(a){
                   Rented[index]=1;
                   cout<<"this house is rented"<<endl;}
           else
                   cout<<" this house is not rented !"<<endl;
        }
 
                
                
        void AvgRentFees(){
                int sum =0;
                for ( int i=0;i<5;i++)
                        sum+=*(homes[i].Rentingfee);
                cout<<"the Average Renting fee is "<<sum/5<<endl;}
 
 
 
        void Cheapest(){
                
                int mini=*(homes[0].Rentingfee);
                string name=*homes[0].nameowner;
                for( int i=0;i<5;i++)
                        if(mini>*(homes[i].Rentingfee)){
                                mini=*(homes[i].Rentingfee);
                                name=*(homes[i].nameowner);}
                        
                        cout<<"the least renting fee is "<<mini<<"and the name of its owner"<<name<<endl;}
 
 
void HomeArea(int index){
        int sum=0;
        int a=*( homes[index].numroom);
        for(int i=0;i<a;i++)
                sum+=homes[index].room[i].Area;
        cout<<"The Total Area of house index"<<index<<"IS;;"<<sum<<endl;}
 
 
void DisplayTowm(){
        cout<<"the name of this Town is "<<&getNameTown<<endl;
        cout<<"the number of objects in this Town is :"<<getNum()<<endl;
        cout<<"this Town includes 5 homes and their info as following :";
                for ( int i=0;i<5;i++){
                        cout<<"info of house "<<i<<" : :";
        Addhouse(homes[i],i);
        homes[i].DisplayHouse();}
};
 
class Room{
private:
    int Area;
        string roomname;
        friend class House;
        friend class Town;
public:
Room( int a, string n){
        setArea(a );
                setroomname( n);}
 
        ~Room(){
                        cout<<"bye room"<<endl;}
                        
        void setArea(int a){
                cout<<"Enter the area of this room ";
                
                cin>>a;
                Area=a;}
 
        int getArea(){
                return Area;}
 
        void setroomname(string n){
                cout<<"Enter the name of this room ";
                cin>>n;
                roomname=n;}
 
        string getnameroom(){
                return roomname;}
 
        void DisplayRoom(){
                cout<<"name of room :"<<&getnameroom<<endl;
                cout<<"room Area:"<<&getArea<<endl;
        }};
    
    void main()
{
    Town d("bayan");
}
 
 
 
 
 
prog.cpp:10: error: ISO C++ forbids declaration of ‘Room’ with no type
prog.cpp:10: error: expected ‘;’ before ‘*’ token
prog.cpp: In destructor ‘House::~House()’:
prog.cpp:21: error: ‘room’ was not declared in this scope
prog.cpp: In member function ‘void House::setRoom(int)’:
prog.cpp:47: error: ‘room’ was not declared in this scope
prog.cpp:47: error: expected type-specifier before ‘Room’
prog.cpp:47: error: expected `;' before ‘Room’
prog.cpp: In member function ‘void House::DisplayHouse()’:
prog.cpp:66: error: ‘room’ was not declared in this scope
prog.cpp: At global scope:
prog.cpp:210: error: expected `}' at end of input
prog.cpp: In constructor ‘Town::Town(std::string)’:
prog.cpp:85: error: no matching function for call to ‘Town::Town()’
prog.cpp:77: note: candidates are: Town::Town(std::string)
prog.cpp:69: note:                 Town::Town(const Town&)
prog.cpp: In member function ‘void Town::Addhouse(House, int)’:
prog.cpp:110: warning: suggest parentheses around assignment used as truth value
prog.cpp: In member function ‘void Town::HomeArea(int)’:
prog.cpp:157: error: ‘class House’ has no member named ‘room’
prog.cpp: In member function ‘void Town::DisplayTowm()’:
prog.cpp:162: error: ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function.  Say ‘&Town::getNameTown’
prog.cpp: In member function ‘void Town::Room::DisplayRoom()’:
prog.cpp:203: error: ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function.  Say ‘&Town::Room::getnameroom’
prog.cpp:204: error: ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function.  Say ‘&Town::Room::getArea’
prog.cpp: At global scope:
prog.cpp:210: error: expected unqualified-id at end of input