Skip to content

R4UBS - #1

Open
AndreyR4UBS wants to merge 1 commit into
mainfrom
dev
Open

AndreyR4UBS wants to merge 1 commit into
mainfrom
dev

Conversation

@AndreyR4UBS

Copy link
Copy Markdown
Owner

Это мой 2 Pull Request/ Сдача 2 спринта. На одну из самых известных автогонок в мире — «24 часа Ле-Мана»

Comment thread src/main/java/Car.java
@@ -0,0 +1,14 @@
class Car {
private String name;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

В этом классе оба поля можно сделать публичными и пометить их final - тогда можно удалить геттеры и получать доступ к полям напрямую по их имени - будет меньше кода, но также надёжно как с геттерами

Comment thread src/main/java/Main.java
}
System.out.println("Самая быстрая машина : " + race.getCurrentLeader().getName());
scanner.close();
} private static String readCarName(Scanner scanner) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Объявление функции лучше перенести на новую строку для повышения читабельности кода

Comment thread src/main/java/Main.java
}
private static int readCarSpeed(Scanner scanner) {
int carSpeed;
while (true) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Не рекомендую писать бесконечные циклы через while (true) - лучше всегда явно прописывать условие выхода из цикла, чтобы уменьшить вероятность ошибиться и повысить читабельность кода

Comment thread src/main/java/Main.java
System.out.println("Введите скорость автомобиля (от 0 до 250 км/ч):");
try {
carSpeed = scanner.nextInt();
if (carSpeed >= 0 && carSpeed <= 250) {

Copy link
Copy Markdown

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.

2 participants