Skip to content

Commit e7d3b16

Browse files
author
Aleksandr Pronichev
committed
fix linter issues
1 parent 4d82797 commit e7d3b16

File tree

6 files changed

+25
-17
lines changed

6 files changed

+25
-17
lines changed

app/src/main/java/hexlet/code/App.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,29 @@ public static void main(String[] args) {
1919
0 - Exit""");
2020

2121
System.out.print("Your choice: ");
22-
int choice = scanner.nextInt();
22+
String choice = scanner.nextLine();
2323
System.out.println();
2424

2525
switch (choice) {
26-
case 1:
26+
case "1":
2727
Cli.greeting();
2828
break;
29-
case 2:
29+
case "2":
3030
Even.gameEven();
3131
break;
32-
case 3:
32+
case "3":
3333
Calc.gameCalc();
3434
break;
35-
case 4:
35+
case "4":
3636
GCD.gameGCD();
3737
break;
38-
case 5:
38+
case "5":
3939
Progression.gameProgression();
4040
break;
41-
case 6:
41+
case "6":
4242
Prime.gamePrime();
4343
break;
44-
case 0:
44+
case "0":
4545
break;
4646
default:
4747
System.out.println("Please select 1, 2, 3, 4, 5, 6 or 0.");

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
public class Calc {
66

77
private static final String RULES = "What is the result of the expression?";
8+
private static final int MAX_NUMBER = 100;
89

910
public static void gameCalc() {
1011
String[] questions = new String[Engine.ROUNDS];
1112
String[] correctAnswers = new String[Engine.ROUNDS];
1213
String[] operators = {"+", "-", "*"};
1314

1415
for (int i = 0; i < Engine.ROUNDS; i++) {
15-
int firstNumber = (int) (Math.random() * 100);
16-
int secondNumber = (int) (Math.random() * 100);
16+
int firstNumber = (int) (Math.random() * MAX_NUMBER);
17+
int secondNumber = (int) (Math.random() * MAX_NUMBER);
1718
String operator = operators[(int) (Math.random() * operators.length)];
1819
questions[i] = firstNumber + " " + operator + " " + secondNumber;
1920

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
public class Even {
66

77
private static final String RULES = "Answer 'yes' if the number is even, otherwise answer 'no'.";
8+
private static final int MAX_NUMBER = 100;
89

910
public static void gameEven() {
1011
String[] questions = new String[Engine.ROUNDS];
1112
String[] correctAnswers = new String[Engine.ROUNDS];
1213

1314
for (int i = 0; i < Engine.ROUNDS; i++) {
14-
int number = (int) (Math.random() * 100);
15+
int number = (int) (Math.random() * MAX_NUMBER);
1516
questions[i] = Integer.toString(number);
1617
if (number % 2 == 0) {
1718
correctAnswers[i] = "yes";

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
public class GCD {
66

77
private static final String RULES = "Find the greatest common divisor of given numbers.";
8+
private static final int MAX_NUMBER = 100;
89

910
public static void gameGCD() {
1011
String[] questions = new String[Engine.ROUNDS];
1112
String[] correctAnswers = new String[Engine.ROUNDS];
1213

1314
for (int i = 0; i < Engine.ROUNDS; i++) {
14-
int firstNumber = (int) (Math.random() * 100);
15-
int secondNumber = (int) (Math.random() * 100);
15+
int firstNumber = (int) (Math.random() * MAX_NUMBER);
16+
int secondNumber = (int) (Math.random() * MAX_NUMBER);
1617
questions[i] = firstNumber + " " + secondNumber;
1718
int gcd = calculateGCD(firstNumber, secondNumber);
1819
correctAnswers[i] = Integer.toString(gcd);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
public class Prime {
66

77
private static final String RULES = "Answer 'yes' if given number is prime. Otherwise answer 'no'.";
8+
private static final int MAX_NUMBER = 100;
89

910
public static void gamePrime() {
1011
String[] questions = new String[Engine.ROUNDS];
1112
String[] correctAnswers = new String[Engine.ROUNDS];
1213

1314
for (int i = 0; i < Engine.ROUNDS; i++) {
14-
int number = (int) (Math.random() * 100);
15+
int number = (int) (Math.random() * MAX_NUMBER);
1516
questions[i] = Integer.toString(number);
1617
if (isPrime(number)) {
1718
correctAnswers[i] = "yes";

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55
public class Progression {
66

77
private static final String RULES = "What number is missing in the progression?";
8+
private static final int MIN_LENGTH = 5;
9+
private static final int MAX_LENGTH = 10;
10+
private static final int MAX_START = 10;
11+
private static final int MAX_STEP = 10;
812

913
public static void gameProgression() {
1014
String[] questions = new String[Engine.ROUNDS];
1115
String[] correctAnswers = new String[Engine.ROUNDS];
1216

1317
for (int i = 0; i < Engine.ROUNDS; i++) {
14-
int progressionLength = (int) (Math.random() * 6) + 5;
15-
int start = (int) (Math.random() * 10);
16-
int step = (int) (Math.random() * 10) + 1;
18+
int progressionLength = (int) (Math.random() * (MAX_LENGTH - MIN_LENGTH + 1)) + MIN_LENGTH;
19+
int start = (int) (Math.random() * MAX_START);
20+
int step = (int) (Math.random() * MAX_STEP) + 1;
1721

1822
int[] progression = new int[progressionLength];
1923

0 commit comments

Comments
 (0)