-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1-7.cpp
108 lines (103 loc) · 1.86 KB
/
1-7.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
#include <iostream>
#include <string>
using namespace std;
class TV;
class Radio {
private:
double mhz, range, signalStrength;
string name, modulation;
static int count;
public:
friend void changeName(Radio&);
friend class TV;
void operator++ () {
modulation = "FM";
}
void operator* () {
range += 1;
}
void operator-- () {
getline(cin, name);
}
Radio() {
mhz = 98.8;
name = "Europa plus";
modulation = "AM";
cin >> range;
cin.get();
signalStrength = 56.8;
count++;
}
Radio(double mhz, string name) {
this->mhz = mhz;
this->name = name;
this->modulation = "AM";
cin >> this->range;
cin.get();
this->signalStrength = 56.8;
count++;
}
Radio(const Radio &Radion) {
name = "Radio NNTU";
mhz = Radion.mhz + 3;
modulation = "FM";
range = 5.6;
signalStrength = 89.2;
count++;
}
~Radio() {
name = "null";
count--;
}
void getInfo() {
cout << name << ' ' << mhz << ' ' << modulation << " - range: " << range << ' ' << "km, signal strength: " << signalStrength << '%' << endl;
}
void AMtoFM() {
if (range > 5) {
if (modulation != "FM") {
modulation = "FM";
range -= 5;
if (signalStrength > 90) {
signalStrength = 100;
}
else {
signalStrength += 10;
}
}
}
}
};
class TV {
public:
void overloadMhz(Radio &p) {
p.mhz -= 1;
}
};
void changeName(Radio &a) {
getline(cin, a.name);
}
int Radio::count;
int main() {
setlocale(LC_ALL, "Russian");
cout << "Ââåäèòå ðàäèóñ ðàäèî:" << endl;
Radio r1;
Radio r2(104.5, "Radio Volga");
Radio r3(r2);
TV t1;
r1.getInfo();
r2.getInfo();
r3.getInfo();
r2.AMtoFM();
r2.getInfo();
cout << "Ñìåíèòå èìÿ ñòàíöèè: " << endl;
changeName(r2);
r2.getInfo();
t1.overloadMhz(r2);
r2.getInfo();
++r1;
*r1;
cout << "Ñìåíèòå èìÿ ñòàíöèè: " << endl;
--r1;
r1.getInfo();
return 0;
}