Skip to content

Conversation

@NS-ClapZz
Copy link
Owner

No description provided.

Comment on lines +2 to +3
String model;
int speed;

Choose a reason for hiding this comment

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

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

if (scanner.hasNextInt()) {
carSpeed = scanner.nextInt();

if (carSpeed > 0 && carSpeed <= 250) {

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 + " (от 0 до 250):");
if (scanner.hasNextInt()) {

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