-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.cpp
More file actions
50 lines (44 loc) · 835 Bytes
/
Copy pathtesting.cpp
File metadata and controls
50 lines (44 loc) · 835 Bytes
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
//
// testing.cpp
//
#include <iostream>
#include <random>
#include <cstdint>
using std::cin;
using std::cout;
class Character {
uint8_t _health;
public:
Character(uint8_t health) : _health(health) {}
void Attack(uint8_t damage) {
if (damage > _health)
_health = 0;
else
_health -= damage;
}
};
class Player : public Character {
public:
Player() : Character(10) {}
};
int main()
{
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dist(1, 10);
int arr[] = { 0, 1, 2 };
cout << arr[3] << std::endl;
int x;
Player player;
while (true)
{
auto val = dist(gen);
player.Attack(val);
cout << "Press 'x' to exit, or any other key to play again" << std::endl;
char c;
cin >> c;
if (c == 'x')
break;
}
return 0;
}