Skip to content

first laba#1

Open
abramukmihail wants to merge 3 commits intomainfrom
dev
Open

first laba#1
abramukmihail wants to merge 3 commits intomainfrom
dev

Conversation

@abramukmihail
Copy link
Copy Markdown
Owner

No description provided.

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


try {
speedCar = Integer.parseInt(speedCars.trim());
if (speedCar < 0 || speedCar > 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.

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

Comment on lines +2 to +3
String liderCar=" ";
int liderDistance=0;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

class Race {
String liderCar=" ";
int liderDistance=0;
void race(String nameCar,int speedCar){
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Нейминг лучше подобрать другой - в названии функции лучше всегда указывать глагол, для данной функции хорошим названием будет evaluateLeader

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