55
66public class Progression {
77 public static void gameLogic () {
8+ final int ARR_LENGTH = 10 ;
9+ final int STEP_MAX = 10 ;
10+ final int HIDE_ELEMENT_MAX = 9 ;
11+ final int FIRST_NUM_MAX = 100 ;
812 Scanner sc = new Scanner (System .in );
9- int [] progression = new int [10 ];
13+ int [] progression = new int [ARR_LENGTH ];
1014 Random randNum = new Random ();
1115
1216 Engine .userGreetings ();
1317 System .out .println ("What number is missing in the progression?" );
14- while (Engine .questionCounter != 3 ) {
15- int progressionStep = randNum .nextInt (1 , 10 );
16- int randHideElement = randNum .nextInt (0 , 9 );
17- int firstNum = randNum .nextInt (1 , 100 );
18+ while (Engine .questionCounter != Engine . MAX_QUESTIONS ) {
19+ int progressionStep = randNum .nextInt (1 , STEP_MAX );
20+ int randHideElement = randNum .nextInt (0 , HIDE_ELEMENT_MAX );
21+ int firstNum = randNum .nextInt (1 , FIRST_NUM_MAX );
1822 progression [0 ] = firstNum ;
1923 for (int i = 1 ; i < progression .length ; i ++) {
2024 progression [i ] = progression [i - 1 ] + progressionStep ;
@@ -41,7 +45,7 @@ public static void gameLogic() {
4145 System .out .println ("Let's try again, " + Engine .userName + "!" );
4246 break ;
4347 }
44- if (Engine .questionCounter == 3 ) {
48+ if (Engine .questionCounter == Engine . MAX_QUESTIONS ) {
4549 System .out .println ("Congratulations, " + Engine .userName + "!" );
4650 }
4751 }
0 commit comments