|
@@ -4,6 +4,7 @@
|
4
|
4
|
import java.util.Scanner;
|
5
|
5
|
import java.util.Random;
|
6
|
6
|
import java.util.InputMismatchException;
|
|
7
|
+import java.util.ArrayList;
|
7
|
8
|
|
8
|
9
|
public class Main {
|
9
|
10
|
|
|
@@ -19,17 +20,39 @@ public class Main {
|
19
|
20
|
boolean game = true;
|
20
|
21
|
int numGuess = 0;
|
21
|
22
|
|
|
23
|
+ ArrayList<Integer>sameGuess = new ArrayList<Integer>();
|
|
24
|
+ //sameGuess.add(guess);
|
|
25
|
+ //System.out.println(sameGuess);
|
|
26
|
+
|
22
|
27
|
while (game){
|
23
|
28
|
if (guess>answer){
|
24
|
29
|
numGuess++;
|
25
|
30
|
System.out.println("Too high, go lower!");
|
|
31
|
+
|
|
32
|
+ if (sameGuess.indexOf(guess)==-1){
|
|
33
|
+ sameGuess.add(guess);
|
|
34
|
+ //numGuess--;
|
|
35
|
+ } else{
|
|
36
|
+ numGuess--;
|
|
37
|
+ //sameGuess.add(guess);
|
|
38
|
+ }
|
26
|
39
|
guess = getNumGuess();
|
27
|
40
|
} else if (guess<answer){
|
28
|
41
|
numGuess++;
|
29
|
42
|
System.out.println("Too low, go higher!");
|
|
43
|
+
|
|
44
|
+ if (sameGuess.indexOf(guess)==-1){
|
|
45
|
+ sameGuess.add(guess);
|
|
46
|
+ //numGuess--;
|
|
47
|
+ } else{
|
|
48
|
+ numGuess--;
|
|
49
|
+ //sameGuess.add(guess);
|
|
50
|
+ }
|
30
|
51
|
guess = getNumGuess();
|
31
|
52
|
} else {
|
32
|
53
|
numGuess++;
|
|
54
|
+
|
|
55
|
+ System.out.println(sameGuess);
|
33
|
56
|
System.out.println("You got it fam!");
|
34
|
57
|
System.out.println("You got the answer in " +numGuess+ " tries.");
|
35
|
58
|
game = false;
|
|
@@ -49,4 +72,6 @@ public class Main {
|
49
|
72
|
|
50
|
73
|
}
|
51
|
74
|
|
|
75
|
+
|
|
76
|
+
|
52
|
77
|
}
|