-
Notifications
You must be signed in to change notification settings - Fork 0
/
book class.cpp
220 lines (181 loc) · 4.19 KB
/
book class.cpp
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
#include <iostream>
#include <string>
using namespace std;
class Country {
private:
string name, capital;
float longitude, latitude;
int population;
public:
void AskInput();
void DisplayAllInfo();
void SetName();
void SetLongitude();
void SetLatitude();
void SetPopulation();
void SetCapital();
void DisplayName();
void DisplayLongitude();
void DisplayLatitude();
void DisplayPopulation();
void DisplayCapital();
};
void DisplayMenu();
void SwitchConditions(Country c);
int main() {
Country c1, c2, c3;
string Name, Capital;
float Longitude, Latitude;
int Population, Code, Ans;
char Ansr;
cout<<"For the First country:"<<endl;
c1.AskInput();
c1.DisplayAllInfo();
cout<<"For the Second country:"<<endl;
c2.AskInput();
c2.DisplayAllInfo();
cout<<"For the Third country:"<<endl;
c3.AskInput();
c3.DisplayAllInfo();
do {
cout<<"Do you want to read or write to current info? (Y/N)\n";
cin>>Ansr;
if(Ansr == 'Y'||Ansr == 'y'){
cout<<"Enter the countrys' code: "<<endl;
c1.DisplayName();
cout<<"'s code: 1\n";
c2.DisplayName();
cout<<"'s code: 2\n";
c3.DisplayName();
cout<<"'s code: 3\n";
cin>>Code;
switch (Code) {
case 1:
SwitchConditions(c1);
c1.DisplayAllInfo();
break;
case 2:
SwitchConditions(c2);
c2.DisplayAllInfo();
break;
case 3:
SwitchConditions(c3);
c3.DisplayAllInfo();
break;
}
}
} while (Ansr == 'Y'|| Ansr =='y');
return 0;
}
void SwitchConditions(Country c){
string Name, Capital;
float Longitude, Latitude;
int Population, Ans;
DisplayMenu();
cin>>Ans;
switch (Ans){
case 1:
c.SetName();
c.DisplayName();
break;
case 2:
c.SetLongitude();
c.DisplayLongitude();
break;
case 3:
c.SetLatitude();
c.DisplayLatitude();
break;
case 4:
c.SetPopulation();
c.DisplayPopulation();
break;
case 5:
c.SetCapital();
c.DisplayCapital();
break;
case 6:
c.DisplayName();
break;
case 7:
c.DisplayLongitude();
break;
case 8:
c.DisplayLatitude();
break;
case 9:
c.DisplayPopulation();
break;
case 10:
c.DisplayCapital();
break;
}
}
void DisplayMenu(){
cout<<"\nEnter the number for the coresponding action: "<<endl;
cout<<"Change country Name: 1\n";
cout<<"Change country Longitude: 2\n";
cout<<"Change country Latitude: 3\n";
cout<<"Change country Population: 4\n";
cout<<"Change country Capital: 5\n";
cout<<"Show country Name: 6\n";
cout<<"Show country Longitude: 7\n";
cout<<"Show country Latitude: 8\n";
cout<<"Show country Population: 9\n";
cout<<"Show country Capital: 10\n\n";
}
void Country :: AskInput(){
cout<<"Enter the name of the Country: ";
cin>>name;
cout<<"Enter the Longitude: ";
cin>>longitude;
cout<<"Enter the Latitude: ";
cin>>latitude;
cout<<"Enter the Population of the country: ";
cin>>population;
cout<<"Enter the Capital of the country: ";
cin>>capital;
cout<<endl;
}
void Country :: DisplayAllInfo(){
cout<<"\nCountry Name: "<<name<<endl;
cout<<"Country Longitude: "<<longitude<<endl;
cout<<"Country Latitude: "<<latitude<<endl;
cout<<"Country Population: "<<population<<endl;
cout<<"Country Capital: "<<capital<<endl<<endl;
}
void Country :: SetName(){
cout<<"Enter the name of the Country: ";
cin>>name;
}
void Country :: SetLongitude(){
cout<<"Enter the Longitude: ";
cin>>longitude;
}
void Country :: SetLatitude(){
cout<<"Enter the Latitude: ";
cin>>latitude;
}
void Country :: SetPopulation(){
cout<<"Enter the Population of the country: ";
cin>>population;
}
void Country :: SetCapital(){
cout<<"Enter the Capital of the country: ";
cin>>capital;
}
void Country :: DisplayName(){
cout<<name;
}
void Country :: DisplayLongitude(){
cout<<longitude;
}
void Country :: DisplayLatitude(){
cout<<latitude;
}
void Country :: DisplayPopulation(){
cout<<population;
}
void Country :: DisplayCapital(){
cout<<capital;
}