-
Notifications
You must be signed in to change notification settings - Fork 0
/
gamesps.java
87 lines (75 loc) · 2.98 KB
/
gamesps.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
package com.company;
import java.util.Random;
import java.util.Scanner;
;
public class gamesps {
public static void main(String[] args){
int i =0;
while(i<=5) {
System.out.println("value 1-> means stone");
System.out.println("value 2-> means paper");
System.out.println("value 3-> means scissor\n");
System.out.println("your turn\n");
Scanner sc = new Scanner(System.in);
int user_choice = sc.nextInt();
System.out.println("computer's turn\n");
Random rm = new Random();
int cmp_choice = rm.nextInt(4);
int u = user_choice;
int c = cmp_choice;
System.out.println("computer choose");
System.out.println(c);
switch (c) {
case 1:
switch (u) {
case 1:
System.out.println("match is tie.....");
break;
case 2:
System.out.println("congrats ! you won the match ");
break;
case 3:
System.out.println("computer won! Gud luck for next match");
break;
default :
System.out.println("you enter a wrong choice");
}
break;
case 2:
switch (u) {
case 1:
System.out.println("computer won! Gud luck for next match");
break;
case 2:
System.out.println("match is tie..... ");
break;
case 3:
System.out.println("congrats ! you won the match");
break;
default :
System.out.println("you enter a wrong choice");
}
break;
case 3:
switch (u) {
case 1:
System.out.println("congrats ! you won the match");
break;
case 2:
System.out.println("computer won! Gud luck for next match");
break;
case 3:
System.out.println("match is tie..... ");
break;
default :
System.out.println("you enter a wrong choice");
}
break;
default:
System.out.println("computer enter a wrong choice ");
break;
}
i++;
}
}
}