Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

First#1

Open
SanguiniAvari wants to merge 2 commits intomain from
dev
Open

First #1
SanguiniAvari wants to merge 2 commits intomain from
dev

Conversation

@SanguiniAvari
Copy link
Owner

@SanguiniAvari SanguiniAvari commented Sep 17, 2024

No description provided.

Comment on lines +22 to +24
/* логика установки скорости с валидацией введенных симоволов и рекурсивно заставляю ввести
верное значение с указанием какие значения от него ожидаются
*/
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В целом по коду уже понятно что делает функция. Здесь не нужен комментарий.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так же комментарии принято писать на английском, но это, конечно, не обязтательно.

Comment on lines +26 to +41
Scanner scanner = new Scanner(System.in);
System.out.println("Введите скорость автомобиля No" + num + ":");
int curentSpeed;
try {
curentSpeed = scanner.nextInt();
if (curentSpeed > 0 && curentSpeed <=250){
speed=curentSpeed;
}else{
System.out.println("Введенное значение находится вне пределов от 1 до 250 включительно. Попробуйте снова.");
setSpeed(num);
}
} catch (InputMismatchException e){
System.out.println("Необходимо ввести число от 1 до 250 включительно.");
setSpeed(num);
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Логичнее было бы хранить num внутри самого класса Car как переменную и задавать в конструкторе.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так же логично было бы вынести всю логику по считыванию из класса Car и оставить тут только простой геттер.

}
//Вычисляем победителя
void whoWinn() {
Car car = new Car();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Переменная создаётся и не используется.

Comment on lines +29 to +40
try {
curentSpeed = scanner.nextInt();
if (curentSpeed > 0 && curentSpeed <=250){
speed=curentSpeed;
}else{
System.out.println("Введенное значение находится вне пределов от 1 до 250 включительно. Попробуйте снова.");
setSpeed(num);
}
} catch (InputMismatchException e){
System.out.println("Необходимо ввести число от 1 до 250 включительно.");
setSpeed(num);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try-catch довольно дорогая операция, правильнее было бы использовать hasNextInt()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@kekulta kekulta kekulta left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /