Skip to content

Commit 8a84e9f

Browse files
committed
rework Progression
1 parent 1423501 commit 8a84e9f

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

app/src/main/java/hexlet/code/games/Progression.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ public class Progression {
1010
private static final int RANDOM_HIDDEN_ELEMENT_BOUND = 10;
1111

1212
public static int[] getRandomProgression() {
13-
1413
int[] progression = new int[PROGRESSION_SIZE];
1514
progression[0] = Engine.getRandomNumber(RANDOM_ELEMENT_OF_PROGRESSION_BOUND);
1615
var step = Engine.getRandomNumber(RANDOM_STEP_BOUND) + 1;
@@ -22,14 +21,16 @@ public static int[] getRandomProgression() {
2221
return progression;
2322
}
2423

25-
public static void start(Scanner scanner) {
26-
Engine.greet(scanner);
27-
System.out.println("What number is missing in the progression?");
24+
public static void start() {
25+
var rules = "What number is missing in the progression?";
26+
var finalRound = Engine.getFinalRound();
27+
28+
String[] questions = new String[finalRound];
29+
String[] correctAnswers = new String[finalRound];
2830

29-
while (Engine.isGameContinuing()) {
31+
for (var i = 0; i < finalRound; i++) {
3032
int[] progression = getRandomProgression();
3133
var hiddenElement = progression[Engine.getRandomNumber(RANDOM_HIDDEN_ELEMENT_BOUND)];
32-
var correctAnswer = Integer.toString(hiddenElement);
3334

3435
StringJoiner progressionForQuestion = new StringJoiner(" ");
3536
for (int num : progression) {
@@ -40,12 +41,10 @@ public static void start(Scanner scanner) {
4041
}
4142
}
4243

43-
System.out.println("Question: " + progressionForQuestion);
44-
45-
var userAnswer = Engine.getUserAnswer(scanner);
46-
Engine.compareAnswers(userAnswer, correctAnswer);
44+
questions[i] = progressionForQuestion.toString();
45+
correctAnswers[i] = Integer.toString(hiddenElement);
4746
}
4847

49-
Engine.end(scanner);
48+
Engine.play(rules, questions, correctAnswers);
5049
}
5150
}

0 commit comments

Comments
 (0)