-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScissorGame.java
More file actions
58 lines (48 loc) · 1.2 KB
/
Copy pathScissorGame.java
File metadata and controls
58 lines (48 loc) · 1.2 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
import java.util.Random;
import java.util.Scanner;
public class ScissorGame{
public static void main(String[] args) {
Random computerInput = new Random();
Scanner input = new Scanner(System.in);
int computer = (int) ((Math.random() *2) + 0);
int counter = 0;
int numWins = 0;
int computerWins = 0;
int scissor = 0;
int rock = 1;
int paper = 2;
int different = 0;
while(counter != 5) {
System.out.println("scissor(0), rock(1), paper(2)");
System.out.print("Guess my number between 0 and 2: ");
int num = input.nextInt();
if (computer == scissor && num == rock) {
System.out.println("You win.");
}
if (computer == rock && num == scissor) {
System.out.println("You lose");
}
if (computer == paper && num == rock) {
System.out.println("You lose");
}
if (computer == rock && num == paper) {
System.out.println("You win");
}
if (computer == paper && num == scissor) {
System.out.println("You win");
}
if (computer == scissor && num == paper) {
System.out.println("You win");
}
if (computer == num) {
System.out.println("Draw Draw");
}
counter = counter + 1;
}
if (numWins % 2 == 0) {
System.out.print("\n You win");
} else {
System.out.print("\n computer win");
}
}
}