-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[자동차 경주 step1] 양두영 미션 제출합니다. #19
base: FhRh
Are you sure you want to change the base?
Changes from 1 commit
643b604
1c60e62
76ee82c
1332d36
480295e
c6b78b0
ed68363
540ba0c
4a8fa93
0aae47d
7322a9a
469efd7
e76d519
128c5b2
1886873
c39982d
fbe849d
6da8a3d
21b64a2
a8747eb
b3dcfca
73495d0
ca514d0
30bb064
0bdeb43
a0631cf
77fff6b
7c200d5
075ae77
ea21bb6
5157d6a
be3bcb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,8 @@ class GameController { | |
for (i in 1..rounds) { | ||
processRound(cars) | ||
} | ||
|
||
GameAnnouncer.printWinners(cars) | ||
val winners = resolveWinners(cars) | ||
GameAnnouncer.printWinners(winners) | ||
} | ||
|
||
private fun processRound(cars: Cars) { | ||
|
@@ -33,4 +33,12 @@ class GameController { | |
} | ||
GameAnnouncer.printCarPositions(cars) | ||
} | ||
|
||
private fun resolveWinners(cars : Cars) : Cars{ | ||
val carList = cars.getCarList() | ||
val maxPosition = carList.maxOf { it.position } | ||
val winners = carList.filter { it.position == maxPosition } | ||
.map { it } | ||
return Cars(winners) | ||
} | ||
Comment on lines
+38
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. private 함수는 테스트하기 힘들죠. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cars 를 받아 Winners 를 구하는 책임을 누군가 가지는게 어떤가요! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아하 심판 도메인을 구현하는 부분 참 좋은 생각인것 같습니다! |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repeat 을 활용해 볼 수 있겠네요:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
유용한 키워드네요 :)