game1 cpp for 777yur0k from Spaces ru include iostream include string

 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
// game1.cpp for 777yur0k from Spaces.ru
#include <iostream>
#include <string>
using namespace std;
class Player
{
private:
int playerHealth, playerPower;
public:
Player(int health, int power)
{
playerHealth = health;
playerPower = power;
}
void setHealth(int health)
{
playerHealth += health;
}
int getHealth() { return playerHealth; }
int getPower() { return playerPower; }
};
void upgradePlayer(Player player)
{
int playerSelect;
cout << "Выберите, что улучшить:" << endl;
cout << "\t1. Здоровье" << endl;
cin >> playerSelect;
switch (playerSelect)
{
default:
break;
case 1:
int upgradedHeatlh = 10;
player.setHealth(upgradedHeatlh);
cout << "Здоровье улучшено на " << upgradedHeatlh << "." << endl;
cout << "Здоровье песронажа: " << player.getHealth() << "." << endl;
break;
}
}
void viewPlayer(Player player)
{
int playerSelect;
cout << "\nОсмотрев своего песронажа со всех сторон вы видете что," << endl;
cout << "у вашего персонажа следующие характеристики:" << endl;
cout << "\tЗдоровье: " << player.getHealth() << endl;
cout << "\tСила: " << player.getPower() << endl << endl;
cout << "Вы можете:" << endl;
cout << "\t1. Вернутся" << endl;
cout << "\t2. Улучшить свои характеристики" << endl;
cin >> playerSelect;
switch (playerSelect)
{
default:
case 1:
break;
case 2:
upgradePlayer(player);
break;
}
}
int main()
{
int playerSelect;
Player player(100, 10);
// Player player = new Player(100, 10);
cout << "Открыв глаза ты видишь перед собой следущие пути:" << endl;
cout << "1. Персонаж" << endl;
cout << "2. Закоулки" << endl;
cout << "3. Площадь" << endl;
cin >> playerSelect;
if (playerSelect == 1)
{
viewPlayer(player);
}
return 0;
}