-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguess.java
More file actions
62 lines (44 loc) · 1 KB
/
guess.java
File metadata and controls
62 lines (44 loc) · 1 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
import java.util.*;
/*class guess extends start{
public static void main(String[] as){
//guess g1 = new guess();
//g1.now();
}
}
*/
class guess extends sps2{
public void now(){
System.out.println("\t\t\t----------GUESS THE NUMBER GAME----------");
System.out.println("\n\t I AM GUESSING A NUMBER BETWEEN 0 TO 9, CAN YOU GUESS IT RIGHT ???");
start s1 = new start();
for(int i = 1; i<=10; i++){
s1.comp();
s1.user();
s1.result();
}
}
}
class sps2{
int rand1 ,u, ptr = 1 ;
public void comp(){
rand1 = (int)(Math.random()*10);
//System.out.println(rand1);
}
public void user(){
Scanner sc = new Scanner(System.in);
System.out.print("\nTAKE A GUESS -->> ");
u = sc.nextInt();
}
public void result(){
if(rand1 == u){
System.out.println("\nYou Guessed It Right !!!!!!!!!");
System.out.println("You took "+ptr+" guesses");
ptr = 1;
}
else{
System.out.println("\nOOPS!! You Missed It Try Again");
ptr++;
//System.out.println(i);
}
}
}