-
Notifications
You must be signed in to change notification settings - Fork 0
secon PR (second changes) #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
ArturNurtdinov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Хорошая работа, молодец!
| String nameAuto; | ||
| int speedAuto; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Поля лучше пометить final, тем самым исключив возможность их модификации извне
| @@ -0,0 +1,12 @@ | |||
| public class autoCar { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Классы в джава и котлине принято называть с большой буквы
| while (true) { | ||
| System.out.println("— Введите название машины № " + i + ":"); | ||
| name = scanner.nextLine().trim(); | ||
| if(!name.isEmpty()){ | ||
| break; | ||
| }else{ | ||
| System.out.println("— Название не может быть пустым!"); | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Код для считывания непустой строки с ввода лучше вынести в отдельную функцию - код, разделённый на небольшие функции, легче читать, поддерживать и переиспользовать
| } | ||
|
|
||
|
|
||
| while (true){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Бесконечные циклы не стоит писать, лучше всегда какое-нибудь условие поставить для повышения читабельности и надёжности
| speed = scanner.nextInt(); | ||
| scanner.nextLine(); | ||
|
|
||
| if(speed > 0 && speed <=250){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Минимальную и максимальную скорости лучше вынести в константы для повышения читабельности кода
В рамках проекта было реализовано консольное приложение «24 часа Ле-Мана».
Приложение запрашивает у пользователя данные трёх автомобилей (название и скорость), валидирует ввод и определяет победителя — автомобиль, который проедет наибольшее расстояние за 24 часа.