-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstonepprscissor.cpp
117 lines (99 loc) · 1.65 KB
/
stonepprscissor.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
114
115
116
117
//Stone Paper Scissor game
#include <iostream>
#include <time.h>
using namespace std;
void stone(int random)
{
if (random == 2)
{
cout << "You lost" << endl;
}
else if (random == 3)
{
cout << "You Won" << endl;
}
else
{
cout << "Draw" << endl;
}
}
void paper(int random)
{
if (random == 3)
{
cout << "You lost" << endl;
}
else if (random == 1)
{
cout << "You Won" << endl;
}
else
{
cout << "Draw" << endl;
}
}
void scissor(int random)
{
if (random == 1)
{
cout << "You lost" << endl;
}
else if (random == 2)
{
cout << "You Won" << endl;
}
else
{
cout << "Draw" << endl;
}
}
void fav()
{
int n;
cout << "select 1.Stone 2.Paper 3.Scissor ";
cin >> n;
srand(time(0));
int random = rand() % 3 + 1;
switch (n)
{
case 1:
stone(random);
break;
case 2:
paper(random);
break;
case 3:
scissor(random);
break;
default:
cout << "It's not a valid Selection \n";
break;
}
}
int main()
{
int a;
bool validator = true;
cout<<"Press Enter to Start the game ";
cin.get();
fav();
while (validator == true)
{
cout << "1.Play Again 2.Exit " << endl;
cin >> a;
if (a == 1)
{
fav();
}
else if (a == 2)
{
validator = false;
cout << "Thanks for playing";
}
else
{
cout << "Oops..! That's the invalid input \n";
}
}
return 0;
}