Skip to content

8/ - #1

Open
Fares6affect wants to merge 3 commits into
mainfrom
dev
Open

8/#1
Fares6affect wants to merge 3 commits into
mainfrom
dev

Conversation

@Fares6affect

Copy link
Copy Markdown
Owner

No description provided.

Comment thread src/main/java/Car.java Outdated
Comment on lines +2 to +3
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, тем самым исключив возожность их модификации извне

Comment thread src/main/java/Main.java Outdated
for(int i=0;i<3;i++){
String name="";
System.out.println("— Введите название машины №"+(i+1)+":");
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 Outdated
System.out.println("— Введите название машины №"+(i+1)+":");
}
int speed;
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.

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

Comment thread src/main/java/Main.java Outdated
}
speed = scanner.nextInt();
scanner.nextLine();
if(speed>=0&&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.

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

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