Repository navigation
Conversation
… обнаружил никаких упомянаний случаев, когда пользователь может указать одинаковые скорости, на всякий случай предусмотрел этот момент. Дольше всего возился с тем, как в метод класса можно засунуть scanner, чтобы посильнее сжать код, не придумал...
Comment on lines
+52
to
+53
| String carName; | ||
| double carSpeed; |
There was a problem hiding this comment.
Поля лучше пометить final, тем самым исключив возможность их модификации извне
Comment on lines
+70
to
+96
| class Winner{ | ||
| String winnerName; | ||
|
|
||
| //Метод для определения победителя с учетом возможного равенства и ничьей | ||
| void whoIs (Car car1, Car car2, Car car3){ | ||
| if (car1.carSpeed > car2.carSpeed && car2.carSpeed > car3.carSpeed) { | ||
| winnerName = "Поздравляем победителя нашего заезда - " + car1.carName; | ||
| } | ||
| if (car2.carSpeed > car1.carSpeed && car2.carSpeed > car3.carSpeed){ | ||
| winnerName = "Поздравляем победителя нашего заезда - " + car2.carName; | ||
| } | ||
| if (car3.carSpeed > car2.carSpeed && car3.carSpeed > car1.carSpeed) { | ||
| winnerName = "Поздравляем победителя нашего заезда - " + car3.carName; | ||
| } | ||
| if (car2.carSpeed == car1.carSpeed && car2.carSpeed > car3.carSpeed){ | ||
| winnerName = "Поздравляем победителей нашего заезда - " + car1.carName + " и " + car2.carName; | ||
| } | ||
| if (car2.carSpeed == car3.carSpeed && car2.carSpeed > car1.carSpeed){ | ||
| winnerName = "Поздравляем победителей нашего заезда" + car3.carName + " и " + car2.carName; | ||
| } | ||
| if (car1.carSpeed == car3.carSpeed && car2.carSpeed < car1.carSpeed){ | ||
| winnerName = "Поздравляем победителей нашего заезда" + car1.carName + " и " + car3.carName; | ||
| } | ||
| if (car2.carSpeed == car1.carSpeed && car2.carSpeed == car3.carSpeed){ | ||
| winnerName = "Всеобщая ничья!!!"; | ||
| } | ||
| } |
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.
No description provided.