forked from fineanmol/hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRPS.java
More file actions
87 lines (63 loc) · 1.72 KB
/
Copy pathRPS.java
File metadata and controls
87 lines (63 loc) · 1.72 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
81
82
83
84
85
86
87
import java.util.Scanner;
// Solution by Gaurav Mishra
public class RPS {
public static void main(String[] args) {
System.out.println("Rock(1) | Paper(2) | Siccoros(3)");
System.out.println("=======================================");
Scanner sc=new Scanner(System.in);
System.out.print("Choose value for player 1 : ");
int player1=sc.nextInt();
// sc.close();
System.out.print("Choose value for player 2 : ");
int player2=sc.nextInt();
sc.close();
if(player1==1){
System.out.println("Player1 choose = Rock");
}else if(player1==2){
System.out.println("Player1 choose = Paper");
}else if(player1==3){
System.out.println("Player1 choose = Siccoros");
}else{
System.out.println("Please choose value between 1 to 3");
}
if(player2==1){
System.out.println("Player2 choose = Rock");
}else if(player2==2){
System.out.println("Player2 choose = Paper");
}else if(player2==3){
System.out.println("Player2 choose = Siccoros");
}else{
System.out.println("Please choose value between 1 to 3");
}
System.out.println("=======================================");
System.out.println("=============== RESULT ================");
System.out.println("=======================================");
switch (player1) {
case 1:
if(player2==2){
System.out.println("Player2 wins");
}else{
System.out.println("Player1 wins");
}
break;
case 2:
if(player2==3){
System.out.println("Player2 wins");
}else{
System.out.println("Player1 wins");
}
break;
case 3:
if(player2==1){
System.out.println("Player2 wins");
}else{
System.out.println("Player1 wins");
}
break;
default:
System.out.println("Try next time");
break;
}
System.out.println("=======================================");
}
}