Skip to content

Initial commit#1

Open
cherrevkoo wants to merge 1 commit into
mainfrom
dev
Open

Initial commit#1
cherrevkoo wants to merge 1 commit into
mainfrom
dev

Conversation

@cherrevkoo
Copy link
Copy Markdown
Owner

No description provided.

Comment thread src/main/java/Auto.java
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/InputRacerData.java

while (true) {
System.out.println("Введите имя гонщика: ");
inputName = scanner.nextLine();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Лучше тут ещё воспользоваться функцией trim(), чтобы не позволять вводить название машин, состоящие только из пробелов и переносов строк

Comment thread src/main/java/Main.java
public static void main(String[] args) {
System.out.println("Hello world!");
Scanner scanner = new Scanner(System.in);
ArrayList<Auto> autos = new ArrayList<>();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

inputSpeed = scanner.nextInt();
scanner.nextLine();

if (inputSpeed > 0 && inputSpeed < 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