-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRockPaperScissorsLizardSpock.java
142 lines (91 loc) · 4.41 KB
/
RockPaperScissorsLizardSpock.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
// Jeffrey Matthew & Justin Acosta
// Rock Paper Scissors (The Big Bang Theory)
// https://www.youtube.com/watch?v=cSLeBKT7-sM
/* Hey there! This is the Big Bang Theory version of RPS, which includes Lizard and Spock.
The idea came from Justin Acosta (teammate), and I was able to write the program.
Feel free to make changes to the code. */
import java.util.Scanner;
public class RockPaperScissorsLizardSpock {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String user_choice, computer_choice = null;
int computer = (int) (Math.random() * 5 + 1);
System.out.println("Welcome to Rock Paper Scissors: Big Bang Theory Edition!\n");
System.out.println("To play, you will need to type in the following choices:\n");
System.out.println(" -Rock -Paper -Scissors");
System.out.println(" -Lizard -Spock\n");
System.out.print("Enter your move: ");
user_choice = in.nextLine();
if (computer == 1)
computer_choice = "Rock";
if (computer == 2)
computer_choice = "Paper";
if (computer == 3)
computer_choice = "Scissors";
if (computer == 4)
computer_choice = "Lizard";
if (computer == 5)
computer_choice = "Spock";
System.out.println("\nComputer chose " + computer_choice + ".\n");
if (user_choice.equals("Rock")) {
if (computer == 1)
System.out.println("You tied!");
if (computer == 2)
System.out.println("Paper has covered Rock. You lost!");
if (computer == 3)
System.out.println("Rock crushes Scissors. You won!");
if (computer == 4)
System.out.println("Rock crushes Lizard. You won!");
if (computer == 5)
System.out.println("Rock has been vaporized by Spock. You lost!");
}
if (user_choice.equals("Paper")) {
if (computer == 1)
System.out.println("Paper has covered Rock. You won!");
if (computer == 2)
System.out.println("You tied!");
if (computer == 3)
System.out.println("Paper has been cut by Scissors. You lost!");
if (computer == 4)
System.out.println("Paper has been eaten by Lizard. You lost!");
if (computer == 5)
System.out.println("Paper has disproved Spock. You won!");
}
if (user_choice.equals("Scissors")) {
if (computer == 1)
System.out.println("Rock has crushed Scissors. You lost!");
if (computer == 2)
System.out.println("Scissors has cut Paper. You won!");
if (computer == 3)
System.out.println("You both tied!");
if (computer == 4)
System.out.println("Scissors has killed Lizard. You won!");
if (computer == 5)
System.out.println("Spock has smashed Scissors. You lost!");
}
if (user_choice.equals("Lizard")) {
if (computer == 1)
System.out.println("Rock has crushed Lizard. You lost!");
if (computer == 2)
System.out.println("Lizard has eaten Paper. You won!");
if (computer == 3)
System.out.println("Lizard has been cut by Scissors. You lost!");
if (computer == 4)
System.out.println("You have tied!");
if (computer == 5)
System.out.println("Lizard has poisoned Spock. You won!");
}
if (user_choice.equals("Spock")) {
if (computer == 1)
System.out.println("Rock has been vaporized by Spock. You won!");
if (computer == 2)
System.out.println("Paper has disproved Spock. You lost!");
if (computer == 3)
System.out.println("Spock smashes Scissors. You won!");
if (computer == 4)
System.out.println("Lizard has poisoned Spock. You lost!");
if (computer == 5)
System.out.println("You tied!");
}
}
}