-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFinal Assignment.cpp
More file actions
342 lines (321 loc) · 8.76 KB
/
Final Assignment.cpp
File metadata and controls
342 lines (321 loc) · 8.76 KB
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
#include<iostream>
#include<string.h>
#include<fstream>
using namespace std;
class property;
class admin;
class buyer
{
private:
string username;
string phonenumber;
int member;
float budget;
float room_size;
char status;
public:
void set_buyer(string a,string b,int c,float d,float e, char f);
friend class property;
} b;
class admin
{
string admin_name;
string password;
float profit;
int property_sold;
public:
admin(string a, string b)
{
admin_name = a;
password = b;
profit = 0;
property_sold = 0;
}
void calculateProfit(float a);
void display_admin(void);
void search_user(string a, string b, admin &d);
} ;
class property
{
private:
string location;
float rent;
float sise;
char status;
public:
void set_property(void);
void display();
void search_property(buyer &i);
float rent_property(void);
float sell_property(void);
} p[10];
void admin :: search_user(string a, string b, admin &d)
{
int j=0, cnt=0;
for(j=0; j<1;)
{
if (d.admin_name == a)
{
if(d.password == b)
{
cout << "Login Successful" << endl;
break;
}
else
{
cnt ++;
if(cnt == 5)
{
cout << "Too many wrong attempt" << endl;
}
else
{
cout << endl;
cout << "Wrong password!!!" << endl;
cout << "Please try Again" << endl;
cout << endl;
cout << "State your name: " << endl;
cin >> a;
cout << "State your password: " << endl;
cin >> b;
j=0;
continue;
}
}
}
else if(j == 0)
{
cnt ++;
if(cnt == 5)
{
cout << "Too many wrong attempt" << endl;
}
else
{
cout << endl;
cout << "Wrong Name!!!" << endl;
cout << "Please try Again" << endl;
cout << endl;
cout << "State your name: " << endl;
cin >> a;
cout << "State your password: " << endl;
cin >> b;
j=0;
continue;
}
}
}
}
void admin :: display_admin(void)
{
cout << "Property Sold or Rented: " << property_sold << endl;
cout << "Profit: " << profit << endl;
}
void admin :: calculateProfit(float a)
{
property_sold++;
profit = a*.15;
}
void property::set_property(void)
{
fstream f;
f.open("Property.txt",ios::in);
int j;
for(j=0; j<10; j++)
{
f >> p[j].location;
f >> p[j].rent;
f >> p[j].sise;
f >> p[j].status;
}
}
void buyer::set_buyer(string a,string b,int c,float d,float e, char f)
{
username = a;
phonenumber = b;
member = c;
budget = d;
room_size = e;
status = f;
}
void property::search_property(buyer &i)
{
for(int j=0; j<10; j++)
{
if(p[j].rent <= i.budget && p[j].status == b.status)
{
if(p[j].sise >= i.room_size)
{
p[j].display();
}
}
}
}
void property::display(void)
{
cout<<"Location: "<<location<<endl;
cout<<"Size: "<<sise<<endl;
cout<<"Price: "<<rent<<endl;
cout<<"Status: "<<status<<endl;
}
float property::rent_property(void)
{
string t;
int j;
char ch;
cout<<"Which property do you want to rent"<<endl;
cin>>t;
for(j=0; j<10; j++)
{
if(p[j].location==t)
{
p[j].display();
cout<<"Do you want to buy this property: Y/N"<<endl;
cin>>ch;
if(ch=='Y')
{
cout<<"You have bought this property"<<endl;
return p[j].rent;
}
else
{
cout<<"Your purchase is cancelled"<<endl;
}
}
}
}
float property::sell_property(void)
{
string t;
int j;
char ch;
cout<<"Which property do you want to buy"<<endl;
cin>>t;
for(j=0; j<10; j++)
{
if(p[j].location==t)
{
p[j].display();
cout<<"Do you want to buy this property: Y/N"<<endl;
cin>>ch;
if(ch=='Y')
{
cout<<"You have bought this property"<<endl;
return p[j].rent;
}
else
{
cout<<"Your purchase is cancelled"<<endl;
}
}
}
}
int main()
{
p[0].set_property();
admin a("Azfar", "2107101");
int cnt;
do
{
cout<<"---------------------Welcome to KAZI HOLDINGS------------------------------"<<endl;
cout << "(a)Login as User" << endl;
cout << "(b)Login as Admin" << endl;
char t1;
cin >> t1;
if(t1 == 'a')
{
do
{
string name,phone;
int mem;
float budge,room;
char f;
cout<<"Enter your name:"<<endl;
cin>>name;
cout<<"Enter your number:"<<endl;
cin>>phone;
cout<<"How many members do you have:"<<endl;
cin>>mem;
cout<<"What's your budget"<<endl;
cin>>budge;
cout<<"what room size do you prefer"<<endl;
cin>>room;
cout<<"What is your choice?"<<endl;
cin>>f;
b.set_buyer(name,phone,mem,budge,room,f);
do
{
cout<<"What do you want to do?"<<endl;
cout<<"1.Search property"<<endl;
cout<<"2.Buy property"<<endl;
cout<<"3.Rent property"<<endl;
int a1;
cin >> a1;
if(a1 == 1)
{
p[6].search_property(b);
cout << "What do you want to do?" << endl;
cout << "1. Logout"<< endl;
cout << "2. Options Menu" << endl;
cout << "3. Main Menu" << endl;
cin >> cnt;
}
else if(a1 == 2)
{
float tp;
tp = p[0].sell_property();
a.calculateProfit(tp);
cout << "What do you want to do?" << endl;
cout << "1. Logout"<< endl;
cout << "2. Options Menu" << endl;
cout << "3. Main Menu" << endl;
cin >> cnt;
}
else if(a1==3)
{
float tp;
tp = p[0].rent_property();
a.calculateProfit(tp);
cout << "What do you want to do?" << endl;
cout << "1. Logout"<< endl;
cout << "2. Options Menu" << endl;
cout << "3. Main Menu" << endl;
cin >> cnt;
}
}
while(cnt == 2);
}
while(cnt == 1);
}
else if(t1 == 'b')
{
do
{
string s1, s2;
cout << "Enter Your User name" << endl;
cin >> s1;
cout << "Enter Your Password" << endl;
cin >> s2;
do
{
a.search_user(s1,s2,a);
cout << "1. Display Profit" << endl;
cout << "2.Logout" << endl;
cout << "3.Main Menu" << endl;
cin >> cnt;
if(cnt == 1)
{
a.display_admin();
cout << "1.Options Menu" << endl;
cout << "2.Logout" << endl;
cout << "3.Main Menu" << endl;
cin >> cnt;
}
}
while(cnt == 1);
}
while(cnt == 2);
}
}
while(cnt == 3);
}