Repository navigation
Приложение функционирует - #1
Open
HESOYAMSPQK wants to merge 2 commits into
Open
HESOYAMSPQK wants to merge 2 commits into
HESOYAMSPQK wants to merge 2 commits into
Conversation
Comment on lines
+2
to
+3
| String name; | ||
| int speed; |
There was a problem hiding this comment.
Поля лучше пометить final, тем самым исключив возможность их модификации извне
| public class Auto { | ||
| String name; | ||
| int speed; | ||
| Auto(String name, int speed) { |
There was a problem hiding this comment.
Т.к. сам класс публичный, конструктору тоже лучше прописать модификатор public
| int speed; | ||
| while (true) { | ||
| System.out.print("Введите скорость машины №" + i + "(от 0 до 250 км/ч): "); | ||
| speed = scanner.nextInt(); |
There was a problem hiding this comment.
Если ввести символы вместо чисел, то здесь вылетит эксепшн, что экстренно завершит выполнение программы с потерей всех введенных данных
Comment on lines
+2
to
+3
| String leader = ""; | ||
| int leaderDistance = 0; |
There was a problem hiding this comment.
Эти переменные лучше сделать приватными, а для получения имени победителя написать отдельную функцию-геттер. Это исключит возможность модификации этих переменных извне, тем самым не позволяя ломать поведение этого класса, т.е. он будет защищённее и стабильнее
…а возможность модификации множества переменных извне. Устранена ошибка при вводе символов.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Выполнил Практическую работу №1, это консольное приложение, которое вычисляет лидера в гонке, при помози тех данных, что ввел пользователь - «24 часа Ле-Мана».