-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathRock_Paper_Scissor.cpp
More file actions
80 lines (65 loc) · 1.4 KB
/
Rock_Paper_Scissor.cpp
File metadata and controls
80 lines (65 loc) · 1.4 KB
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
#include <iostream>
#include <stdlib.h>
int main() {
srand (time(NULL));
int computer = rand() % 3 + 1;
int user = 0;
//Creating strings to avoid repetition
std::string roc = "1) ✌Rock\n";
std::string pap = "2) ✋Paper\n";
std::string sci = "3) ✌️Scissors\n";
std::cout << "====================\n";
std::cout << "rock paper scissors!\n";
std::cout << "====================\n";
std::cout << roc;
std::cout << pap;
std::cout << sci;
std::cout << "Choose: ";
std::cin >> user;
std::cout << "\nYou choose ";
//Displaying user choice
switch(user){
case 1 :
std::cout << roc;
break;
case 2 :
std::cout << pap;
break;
case 3 :
std::cout << sci;
break;
default :
std::cout << "Invalid Option\n";
}
//Displaying computer choice
std::cout << "Comp choose ";
switch(computer){
case 1 :
std::cout << roc;
break;
case 2 :
std::cout << pap;
break;
case 3 :
std::cout << sci;
break;
default :
std::cout << "Invalid Option\n";
}
//Win Lose Draw Logic
if(user == computer){
std::cout << "Draw Game\n";
}
else if(user == 1 && computer == 3){
std::cout << "You Win\n";
}
else if(user == 3 && computer == 2){
std::cout << "You Win\n";
}
else if(user == 2 && computer == 1){
std::cout << "You Win\n";
}
else{
std::cout << "Computer Wins!\n";
}
}