-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathRockPaperScissor.java
145 lines (63 loc) · 2.21 KB
/
RockPaperScissor.java
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//Rock Paper Scissor Game
package Rameez;
import java.util.*;
public class Main {
public static void main(String[] args) {
// public static void main(String[] args) { // Rock paper Scissor Game
int victory = 0;
int Rock = 0 , Paper = 1, Scissor = 2 ;
int turn ;
Scanner zap = new Scanner(System.in);
Random ram = new Random();
System.out.println("This is a Rock- Paper-Scissor Game ");
System.out.println(" Press Number Accordingly \n Rock --> 0\n Paper --> 1\n Scissor --> 2 \n ");
System.out.println(" This Game has 5 Rounds ");
for(int step = 1 ; step<= 5; step++){
System.out.println(" ******* Round 0" + step + " ********\n --> Computer's has Choosen the number\n ");
int player1 = ram.nextInt(2);
System.out.println(" --> Your's Turn ");
int player2 = zap.nextInt();
while (player2 < 0 || player2 >= 3)
{
System.out.println(" Please enter the number between 0-2 \n Enter the number again ");
player2=zap.nextInt();
}
if (player1==player2){
System.out.println(" Both choose same Weapon \n Match Tie !! ");
}
else
{
if (player1==0 && player2 == 1){
System.out.println(" You wins !! ");
victory+= 1;
}
else if (player1==1 && player2 == 0)
{
System.out.println(" You loss !! ");
System.out.println("Computer's Choice is " + player1 + " ( Paper )");
}
else if (player1==2 && player2 == 1)
{
System.out.println(" You loss !! ");
System.out.println("Computer's Choice is " + player1 + " ( Scissor )");
}
else if (player1==1 && player2 == 2){
System.out.println(" You wins !! ");
victory+= 1;
}
else if (player1== 2 && player2 == 0){
System.out.println(" You wins !! ");
victory+= 1; }
else if (player1== 0 && player2 == 2)
{
System.out.println(" You loss !! ");
System.out.println("Computer's Choice is " + player1 + " ( Rock )");
}
}
System.out.println("\n__________________________\n");
if (step == 5 ){
System.out.println( " Your Total Victories are " + victory +
" \n ******* Game End ******* " + "\n *** Programed By Muhammad Rameez ***\n ***** Gcu Lahore (0090-Bscs-20) *****");
}}
}
}