Trinh Tong před 6 roky
rodič
revize
623d7318e0

binární
TooLargeTooSmall/TooLargeTooSmall.class Zobrazit soubor


+ 6
- 7
TooLargeTooSmall/TooLargeTooSmall.java Zobrazit soubor

10
 import java.util.*;
10
 import java.util.*;
11
 
11
 
12
 public class TooLargeTooSmall {
12
 public class TooLargeTooSmall {
13
-
14
     public static int randomNumGenerator(){
13
     public static int randomNumGenerator(){
15
         // this section starts the game by letting the user select
14
         // this section starts the game by letting the user select
16
         // a game mode
15
         // a game mode
58
         
57
         
59
         Scanner keyboard = new Scanner(System.in);
58
         Scanner keyboard = new Scanner(System.in);
60
         // While loop until guess is correct.
59
         // While loop until guess is correct.
61
-        // interacts with other methods
62
         // guess checker - will check guess against other guesses
60
         // guess checker - will check guess against other guesses
63
         // boolean, if currentGuess = previousGuess, repeatGuess = true/false
61
         // boolean, if currentGuess = previousGuess, repeatGuess = true/false
64
         
62
         
77
                 guessFound = true;
75
                 guessFound = true;
78
 
76
 
79
             } else {
77
             } else {
80
-                // check guess
78
+                // check guess against previous guess update counter
81
                 if (currentGuess != previousGuess) {
79
                 if (currentGuess != previousGuess) {
82
                     guessCounter++;
80
                     guessCounter++;
83
                     previousGuess = currentGuess;
81
                     previousGuess = currentGuess;
84
                 }
82
                 }
83
+                if (currentGuess > numberToGuess) {
84
+                    System.out.println("Number was too large!");
85
+                } else {
86
+                    System.out.println("Number was too small!");
87
+                }
85
                 System.out.println("That wasn't the right answer. Guess again!");
88
                 System.out.println("That wasn't the right answer. Guess again!");
86
             }
89
             }
87
         }
90
         }
88
-        
89
-        System.out.println("");
90
-        
91
     }
91
     }
92
-    
93
 }
92
 }