This repository has been archived by the owner on Apr 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PART_12.cpp
111 lines (106 loc) · 2.25 KB
/
PART_12.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
#include"FOR_ALL_TASKS.h"
//TASK 1
int main()
{
char s1[80];
gets_s(s1);
int size = strlen(s1);
char* start = s1; char* end; end = &s1[size - 1];
while (start <= end)
{
cout << *end;
--end;
}
}
//TASK 3
const int SIZE = 10, COUNT = 2;
enum TYPES { FORMALIST = 1, NEFORMAL, REALIST };
string names[SIZE]{ "Aleksander", "Andrew", "Anastasiya", "Irina", "Nataly","Pavel", "Roman", "Svetlana","Sergei", "Tany" };
class Realist
{
public:
string name = names[rand() % 10], type1 = "Realist", myname = "My name is ", im = "I'm ";
string arr_names[COUNT];
int age = rand() % 40 - 20;
virtual void about()
{
cout << myname << name << im << age << "and i'm " << type1;
}
virtual void hello(int h_age, int age = 0)
{
if (h_age <= this->age || h_age - this->age <= 5)
{
cout << "Hello " << arr_names[0] << endl;
cout << "Hello " << arr_names[1] << endl;
}
else
{
cout << "Greetings" << arr_names[0] << endl;
cout << "Greetings " << arr_names[1] << endl;
}
}
virtual void arr_n(string ob1, string ob2)
{
arr_names[0] = ob1;
arr_names[1] = ob2;
}
string get_name() { return name; }
};
class Formalist :Realist
{
public:
string type2 = "Formalist";
void about()
{
cout << myname << name << im << age << "and i'm " << type2;
}
void hello()
{
cout << "Greetings " << arr_names[0] << endl;
cout << "Greetings " << arr_names[1] << endl;
}
void arr_n(string ob1, string ob2)
{
arr_names[0] = ob1;
arr_names[1] = ob2;
}
string get_name() { return name; }
int get_age() { return age; }
};
class Neformal :Realist
{
public:
string type3 = "Neformal";
void about()
{
cout << myname << name << im << age << "and i'm " << type3;
}
void hello()
{
cout << "Hello " << arr_names[0] << endl;
cout << "Hello" << arr_names[1] << endl;
}
void arr_n(string ob1, string ob2)
{
arr_names[0] = ob1;
arr_names[1] = ob2;
}
string get_name() { return name; }
int get_age() { return age; }
};
int main()
{
Realist real;
Formalist form;
Neformal neform;
real.about();
form.about();
neform.about();
real.arr_n(form.get_name(), neform.get_name());
form.arr_n(real.get_name(), neform.get_name());
neform.arr_n(real.get_name(), form.get_name());
real.hello(form.get_age());
real.hello(neform.get_age());
form.hello();
neform.hello();
}