-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.java
More file actions
74 lines (70 loc) · 2.08 KB
/
game.java
File metadata and controls
74 lines (70 loc) · 2.08 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
import java.util.Scanner;
public class game
{
public static String randomWord()
{
double a = Math.random()*2;
int b=(int)a;
if (b==0)
{
return "rock";
}
if (b==1)
{
return "paper";
}
if (b==2)
{
return "scissor";
}
return "0";
}
public static void main(String[] args)
{
String cch=randomWord();
Scanner sc = new Scanner(System.in);
System.out.println("Let's play Rock Paper Scissors");
System.out.println("When I say 'shoot', Choose: rock, paper, or scissors\nAre you ready? Write 'yes' if you are\n");
String ab=sc.nextLine();
if (ab.equals("yes"))
{
System.out.println("great");
System.out.println("rock -- paper -- scissors, shoot!");
String ch=sc.nextLine();
System.out.println("you chose "+ch);
System.out.println("computer chose "+cch);
if(ch.equals("rock")&&cch.equals("scissor"))
{
System.out.println("you won");
}
else if(ch.equals("paper")&&cch.equals("rock"))
{
System.out.println("you won");
}
else if(ch.equals("scissor")&&cch.equals("paper"))
{
System.out.println("you won");
}
else if(ch.equals("rock")&&cch.equals("rock"))
{
System.out.println("Its a draw!");
}
else if(ch.equals("scissor")&&cch.equals("scissor"))
{
System.out.println("Its a draw!");
}
else if(ch.equals("paper")&&cch.equals("paper"))
{
System.out.println("Its a draw!");
}
else
{
System.out.println("computer won");
}
}
else
{
System.out.println("Darn, some other time... ");
}
}
}