Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Проектная работа No1#1

Open
xabko wants to merge 1 commit intomain from
dev
Open

Проектная работа No1 #1
xabko wants to merge 1 commit intomain from
dev

Conversation

@xabko
Copy link
Owner

@xabko xabko commented Nov 2, 2025

/

public static void main(String[] args) {
System.out.println("Hello world!");
Scanner scanner = new Scanner(System.in);
Car[] cars = new Car[3];
Copy link

@ArturNurtdinov ArturNurtdinov Nov 2, 2025

Choose a reason for hiding this comment

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

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

speed = Integer.parseInt(input);

// Проверяем диапазон
if (speed <= 0 || speed > 250) {
Copy link

@ArturNurtdinov ArturNurtdinov Nov 2, 2025

Choose a reason for hiding this comment

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

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


try {
// Проверяем на дробное число
if (input.contains(".") || input.contains(",")) {
Copy link

@ArturNurtdinov ArturNurtdinov Nov 2, 2025

Choose a reason for hiding this comment

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

Уже есть обработка NumberFormatException , поэтому от этой проверки можно отказаться

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@ArturNurtdinov ArturNurtdinov ArturNurtdinov left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /