-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRockPaperScissor.java
More file actions
69 lines (63 loc) · 1.51 KB
/
RockPaperScissor.java
File metadata and controls
69 lines (63 loc) · 1.51 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
class RockPaperScissor {
public static void main (String [] args) {
// String p1 = args[0];
// String p2 = args[1];
String input1 = args[0];
String input2 = args[1];
// String one = "Player One win!";
// String two = "Player Two win!";
// String wgInput = "Wrong Input!!!";
String result;
// String result = p1.equals(p2)
// ? "It's DRAW"
// : "r".equals(p1)
// ? "s".equals(p2)
// ? one
// : "p".equals(p2)
// ? two
// : wgInput
// : "s".equals(p1)
// ? "r".equals(p2)
// ? two
// : "p".equals(p2)
// ? one
// : wgInput
// : "p".equals(p1)
// ? "r".equals(p2)
// ? one
// : "s".equals(p2)
// ? two
// : wgInput
// : wgInput;
if(input1.equals(input2)) {
result = "It's Draw";
} else if ("r".equals(input1)) {
if ("p".equals(input2)) {
result = "Player Two win!";
} else if ("s".equals(input2)) {
result = "Player One win!";
} else {
result = "Wrong Input!!!";
}
} else if ("p".equals(input1)) {
if ("r".equals(input2)) {
result = "Player One win!";
} else if ("s".equals(input2)) {
result = "Player Two win!";
} else {
result = "Wrong Input!!!";
}
} else if ("s".equals(input1)) {
if ("r".equals(input2)) {
result = "Player Two win!";
} else if ("p".equals(input2)) {
result = "Player One win!";
} else {
result = "Wrong Input!!!";
}
} else {
result = "Wrong Input!!!";
}
System.out.println(result);
}
}