forked from OxyNett/1_184_2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChildOOP.cpp
113 lines (105 loc) · 3.18 KB
/
ChildOOP.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
/*
У ребенка есть несколько состояний: играть, есть, спать
Состояния приватные.
Мы с ним можем поиграть, покормить, уложить спать.
Мы можем создавать ребенка с различными конфигурациями состояний.
*/
#include <iostream>
#include <cstring>
using namespace std;
class Child
{
private:
int Age;
string Name;
double WhatChildWant; // Переменная, которая в будущем будет использоваться для проверки условий из Display
public:
Child()
{
this->Name = Name;
this->Age = Age;
}
void Display()
{
cout << "1 - Child wants eat" << endl << "2 - Child wants play" << endl << "3 - Child wants sleep" << endl << "1.2 - Child wants Eat and Play" << endl << "1.3 - Child wants Eat and Sleep" << endl;
}
void Input()
{
cout << "What's your child's name? "; cin >> Name; cout << endl;
cout << "The age of " << Name << "? "; cin >> Age; cout << endl;
}
void Compare()
{
cout << "What your child wants: Eat, Game or Sleep? " << endl;
cin >> WhatChildWant;
if (Age < 6) // Если Ребенку меньше 6 лет, то мы будем выполнять одни действия
{
if (WhatChildWant == 1)
{
cout << Name << " wants eat, prepare a meal and ask the child what HE/SHE want. " << endl;
}
else if (WhatChildWant == 2)
{
cout << "plays with " << Name << " or turn on cartoons." << endl;
}
else if (WhatChildWant == 3)
{
cout << Name << " want sleeps, air out the room and read a story. " << endl;
}
else if (WhatChildWant == 1.2)
{
cout << Name << " wants eat and plays. Prepare food, you can arrange an interactive game with cooking" << endl;
}
else if (WhatChildWant == 1.3)
{
cout << Name << " wants eat and sleeps. Urgently prepare a light meal, put the child to bed, read the story" << endl;
}
else
{
cout << "What " << Name << " wants?" << endl;
}
}
else // Если ребенку больше 6, то мы выполняем действия, связанные с его самостоятельностью
{
if (WhatChildWant == 1)
{
cout << Name << " want eats, try cooking with " << Name << ", if it works, it's cool! " << endl;
}
else if (WhatChildWant == 2)
{
cout << "play with " << Name << " or turn on cartoons." << endl;
}
else if (WhatChildWant == 3)
{
cout << Name << " want sleeps, ventilate the room. Ask if " << Name << " wants a story, and if not, wish him sweet dreams. " << endl;
}
else if (WhatChildWant == 1.2)
{
cout << Name << " wants eat and plays. Prepare food, you can arrange an interactive game with cooking" << endl;
}
else if (WhatChildWant == 1.3)
{
cout << Name << " wants eats and sleeps. Urgently prepare a light meal, put the child to bed, read the story" << endl;
}
else
{
cout << "What " << Name << " wants?" << endl;
}
}
}
~Child()
{
cout << endl;
}
};
int main()
{
Child my_child1;
my_child1.Display();
my_child1.Input();
while (true)
{
my_child1.Compare();
}
return 0;
}