-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoin.cpp
More file actions
42 lines (38 loc) · 901 Bytes
/
Coin.cpp
File metadata and controls
42 lines (38 loc) · 901 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
#include "Coin.h"
Coin::Coin():Game()
{
game_name="Ìîíåòêà";
}
string Coin::coin2str(int p)
{
string result;
if (p==1)
result = "Îð¸ë";
else
if (p==2)
result = "Ðåøêà";
else
result = "???";
return result;
}
GameResults Coin::Play()
{
GameResults result;
int user_choice, comp_choice;
string error_coin="Îøèáêà, âûáèðàéòå 1 èëè 2!";
cout << "Âàø âûáîð? " << endl << "\n1 - Îð¸ë" << endl << "\n2 - Ðåøêà" << endl << endl;
cin >> user_choice;
if (user_choice == 1 || user_choice == 2)
{
comp_choice = 1+rand()%2;
cout << endl << "Âàø âûáîð: " << coin2str(user_choice) << endl;
cout << "Âûïàëî: " << coin2str(comp_choice) << endl << endl;
}
else
throw (error_coin);
if (user_choice == comp_choice)
result = grWin;
else
result = grLose;
return result;
}