Skip to content

Commit

Permalink
Progression
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovsenka committed Jun 2, 2024
1 parent 65a83b5 commit c5c08af
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/src/main/java/hexlet/code/games/ProgressionGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
import java.util.Random;

public class ProgressionGame {
private static final StringBuilder PROGRESSION = new StringBuilder();
private static final Random RANDOM = new Random();
public static void runGame() {
Engine.score = 0;
while (Engine.score != Engine.COUNT_ROUNDS) {
StringBuilder progression = new StringBuilder();
int d = RANDOM.nextInt(10) + 1;
int value = RANDOM.nextInt(25) + 1;
int lengthProgression = RANDOM.nextInt(8) + 5;
int position = RANDOM.nextInt(lengthProgression);
String correctAnswer = "";
for (int i = 0; i < lengthProgression; i++) {
if (i == position) {
PROGRESSION.append(".. ");
progression.append(".. ");
correctAnswer = String.valueOf(value);
} else {
PROGRESSION.append(value).append(" ");
progression.append(value).append(" ");
}
value += d;
}
if (!Engine.startRound(PROGRESSION.toString(), correctAnswer)) {
if (!Engine.startRound(progression.toString(), correctAnswer)) {
break;
}
}
Expand Down

0 comments on commit c5c08af

Please sign in to comment.