Skip to content

Conversation

@ChupakabrikSSS
Copy link
Owner

В рамках проекта было реализовано консольное приложение «24 часа Ле-Мана».
Приложение запрашивает у пользователя данные трёх автомобилей (название и скорость), валидирует ввод и определяет победителя — автомобиль, который проедет наибольшее расстояние за 24 часа.

Copy link

@ArturNurtdinov ArturNurtdinov left a comment

Choose a reason for hiding this comment

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

Хорошая работа, молодец!

Comment on lines +3 to +4
String nameAuto;
int speedAuto;

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 {

Choose a reason for hiding this comment

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

Классы в джава и котлине принято называть с большой буквы

Comment on lines +13 to +22
while (true) {
System.out.println("— Введите название машины № " + i + ":");
name = scanner.nextLine().trim();
if(!name.isEmpty()){
break;
}else{
System.out.println("— Название не может быть пустым!");
}

}

Choose a reason for hiding this comment

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

Код для считывания непустой строки с ввода лучше вынести в отдельную функцию - код, разделённый на небольшие функции, легче читать, поддерживать и переиспользовать

}


while (true){

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){

Choose a reason for hiding this comment

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

Минимальную и максимальную скорости лучше вынести в константы для повышения читабельности кода

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants