-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.cpp
More file actions
94 lines (63 loc) · 2.01 KB
/
2.cpp
File metadata and controls
94 lines (63 loc) · 2.01 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
#include <iostream>
#include <string.h>
using namespace std;
struct Vector3 {
public:
int x, y, z;
string ToString() {
return "[" + to_string(x) + ", " + to_string(y) + ", " + to_string(z) + "]";
}
};
enum Gender {
Male,
Female
};
class Person {
public:
short Age;
string Name;
Gender gender;
Vector3 position;
Person(short age, string name, string gender, Vector3 vector) {
this->Age = age;
this->Name = name;
this->gender = (gender == "Male" ? Male : Female);
this->position = vector;
}
string ToString() {
return "[" + Name + ", " + to_string(Age) + ", " + (gender == Male ? "Male" : "Female") + "]";
}
void Equals(Person anotherPerson) {
cout << endl;
cout << "Персонаж 1 - " << Name << endl;
cout << "Персонаж 2 - " << anotherPerson.Name << endl;
cout << endl;
if ((Name == anotherPerson.Name) && (Age == anotherPerson.Age) && (gender == anotherPerson.gender)) {
cout << "У персонажей одинаковые пол, возраст и имя" << endl;
} else {
cout << "Персонажи разные" << endl;
}
}
void Translate(Vector3 translation) {
cout << "Начальные координаты: " << endl;
cout << position.ToString();
cout << endl;
cout << "Вектор перемещения: " << endl;
cout << translation.ToString() << endl;
position.x += translation.x;
position.y += translation.y;
position.z += translation.z;
cout << "Координаты после перемещения: " << endl;
cout << position.ToString();
cout << endl;
}
};
int main() {
Vector3 vector1 = {1, 2, 44};
Vector3 vector0 = {0, 0, 0};
Person Ivan = Person(19, "Ivan", "Male", vector0);
Ivan.Translate(vector1);
Vector3 vector2 = {13, 25, 44};
Ivan.Translate(vector2);
return 0;
}