Skip to content

Comments

Привет#1

Open
ZhannaVell wants to merge 2 commits intomainfrom
dev
Open

Привет#1
ZhannaVell wants to merge 2 commits intomainfrom
dev

Conversation

@ZhannaVell
Copy link
Owner

Это мoя первая проектная работа, вы только посмотрите! (≧◡≦)

Comment on lines 2 to 3
private String name;
private int speed;

Choose a reason for hiding this comment

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

Поля лучше пометить final, тем самым исключив возможность их модификации извне. Тогда поля можно сделать публичными и удалить геттеры

System.out.println("Введите скорость автомобиля № " + (i + 1) + " (1-250 км/ч):");
try {
speed = scanner.nextInt();
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.

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

}
int speed = 0;
boolean validSpeed = false;
while (!validSpeed) {

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