Skip to content

Практическая работа №1#1

Open
ilyateplov wants to merge 2 commits intodevfrom
version1
Open

Практическая работа №1#1
ilyateplov wants to merge 2 commits intodevfrom
version1

Conversation

@ilyateplov
Copy link
Copy Markdown
Owner

No description provided.

Comment on lines +3 to +4
String name;
int speed;
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, тем самым исключив возможность их модификации извне

Copy link
Copy Markdown
Owner Author

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 + ":");
speed = scanner.nextInt();
if ((0 > speed) || (speed > 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.

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

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Исправил

int speed;
while (true) {
System.out.println("Введите скорость машины №" + i + ":");
speed = scanner.nextInt();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Здесь может быть выброшен эксепшн, его необходимо обработать

Copy link
Copy Markdown
Owner Author

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