-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRPSGame.java
More file actions
88 lines (87 loc) · 3.74 KB
/
RPSGame.java
File metadata and controls
88 lines (87 loc) · 3.74 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
88
import java.util.Random;
import java.util.Scanner;
class RPSGame {
public static void main(String args[]) {
Random roll = new Random();
int min = 1;
int max = 3;
// Random Bot roll
int B_roll = roll.nextInt((max - min) + 1) + min;
int B_throw = B_roll;
Scanner P_in = new Scanner(System.in);
System.out.println("What do you what to throw?\r\n" + //
" 1. Rock\r\n" + //
" 2. Paper\r\n" + //
" 3. Scissor");
int P_throw = P_in.nextInt();
P_in.close();
// Player Throws
if (P_throw == 1) {
System.out.println("Player:\r\n" + //
" ________\r\n" + //
"---' ______)\r\n" + //
" (______)\r\n" + //
" (______)\r\n" + //
" (_____)\r\n" + //
"---.___(____)");
} else if (P_throw == 2) {
System.out.println("Player:\r\n" + //
" _______\r\n" + //
"---' ____)______\r\n" + //
" ________)\r\n" + //
" ________)\r\n" + //
" ________)\r\n" + //
"---.___________)");
} else if (P_throw == 3) {
System.out.println("Player:\r\n" + //
" _______\r\n" + //
"---' ____)_______\r\n" + //
" _________)\r\n" + //
" ___________)\r\n" + //
" (_____)\r\n" + //
"---.__(____)");
}
// Bot throws
if (B_roll == 1) {
System.out.println(" Bot :\r\n" + //
" _________\r\n" + //
" (_______ '---\r\n" + //
" (_____)\r\n" + //
" (_____)\r\n" + //
" (____)\r\n" + //
" (___)___.---");
} else if (B_roll == 2) {
System.out.println(" Bot :\r\n" + //
" _________\r\n" + //
" ____(____ '---\r\n" + //
" (______\r\n" + //
" (_______\r\n" + //
" (_______\r\n" + //
" (___________.---");
} else if (B_roll == 3) {
System.out.println(" Bot :\r\n" + //
" _______\r\n" + //
" _____(____ '---\r\n" + //
" (_______\r\n" + //
" (__________\r\n" + //
" (_____)\r\n" + //
" (____)__.---");
}
// Check Winner
if (P_throw == B_throw) {
System.out.println("---Tie---");
} else if (P_throw == 1 && B_throw == 2) {
System.out.println("---Bot Wins---");
} else if (P_throw == 1 && B_throw == 3) {
System.out.print("---Player Wins---");
} else if (P_throw == 2 && B_throw == 1) {
System.out.print("---Player Wins---");
} else if (P_throw == 2 && B_throw == 3) {
System.out.print("---Bot Wins---");
} else if (P_throw == 3 && B_throw == 1) {
System.out.print("---Bot Wins---");
} else if (P_throw == 3 && B_throw == 2) {
System.out.print("---Player Wins---");
}
}
}