-
Notifications
You must be signed in to change notification settings - Fork 411
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
π 5λ¨κ³ - μλμ°¨ κ²½μ£Ό(리ν©ν°λ§) #1742
base: aimbe
Are you sure you want to change the base?
Conversation
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.
μλ νμΈμ μ νΈλ! κ°μ¬μ€λ₯Ό λ€μ μ½κ³ κ³μλκ΅°μ! λμμ΄ λμλ€λ κΈ°μ©λλ€ π
μ΄μ μ λΉν΄μ λ©μΈμ§λ₯Ό μ λ¬νλ κ³Όμ μ΄ λ "λ₯λμ μΈ" κ°μ²΄μ μ±
μμΌλ‘ μ΄μ΄μ§ κ² κ°μμ.
λ§μ§λ§ λ¨κ³μΈ λ§νΌ λμ μ μΈ μ½λ©νΈλ₯Ό λͺ κ°μ§ λ¬μμ΅λλ€.
κΆκΈν μ μ΄λ λ Όμνκ³ μΆμ λ΄μ©μ΄ μμΌλ©΄ μΈμ λ μλ €μ£ΌμΈμ!
@@ -20,9 +22,9 @@ class PlayGame(private val racingCars: RacingCars, private val attempts: Int) { | |||
fun play() { | |||
repeat(attempts) { | |||
racingCars.moveAll { (0..9).random() } | |||
printRoundResult(racingCars.getPositionsWithName()) | |||
printRoundResult(racingCars) |
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.
λ§μ§λ§ λ¨κ³μΈ λ§νΌ μ’ λ κ°μ ν΄λ³Ό μ μλ μ¬λ¬ μμ΄λμ΄λ₯Ό μ μνκ³ μΆμ΄μ π
ResultView νΈμΆμ μ΅λν μ€μ¬λ³΄λ©΄ μ΄λ¨κΉμ?
μ°λ¦¬κ° νν μΉ νλ‘κ·Έλ¨μμ μλ²μ ν΄λΌμ΄μΈνΈ κ°μ μν΅νλκ±Έ μκ°ν΄λ³΄λ©΄
μλ²μ ν΄λΌμ΄μΈνΈκ° μλ‘ μμ²κ³Ό μλ΅μ μ£Όκ³ λ°λ κ³Όμ μ λͺ¨λ λΉμ©μ
λλ€. μ΄λ¬ν λΉμ©μ μ€μ΄λ κ²μ΄ μΉ νλ‘κ·Έλλ°μμ μ€μνκ² μ¬κ²¨μ§κΈ°λ ν©λλ€.
λ μ§κΈμ λ¨μν μ½μ νλ‘κ·Έλ¨μ΄μ§λ§, λμ€μ λ·°κ° μλλ‘μ΄λ μ±μΌλ‘ λ°λλ€λμ§, μΉνμ΄μ§ λ±μΌλ‘ λ°λλ€κ³ νλ©΄ μ΄λ¬ν νΈμΆμ΄ λͺ¨λ λΉμ©μ΄ λ©λλ€.
class CarPositionFormatter { | ||
companion object { | ||
fun formatCarPosition(car: RacingCar): String { | ||
return "μλμ°¨ ${car.name} : ${formatPosition(car.position)}" |
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.
λ·° μꡬ μ¬νμ μμ‘΄νκ³ μλ μ΄ λ‘μ§μ΄ domain
ν¨ν€μ§μ μλ κ²μ΄ μ μ ν κΉμ?
MVC ν¨ν΄ κΈ°λ°μΌλ‘ 리ν©ν λ§ν΄ view ν¨ν€μ§μ κ°μ²΄κ° domain ν¨ν€μ§ κ°μ²΄μ μμ‘΄ν μ μμ§λ§, domain ν¨ν€μ§μ κ°μ²΄λ view ν¨ν€μ§ κ°μ²΄μ μμ‘΄νμ§ μλλ‘ κ΅¬ννλ€.
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.
μ무λλ domainμ μκΈ΄ μλ§κ³ viewμ μκΈ°μλ μ 맀ν΄μ util ν¨ν€μ§ μμ± ν μ΄λμμΌ°μ΅λλ€! γ γ
package misson.car.domain | ||
|
||
// μ½νλ¦° λ¬Έλ²μμ positionμ privateμΌλ‘ νμ§ μμλ λ΄λΆμ μΌλ‘λ getterλ‘ μ κ·Ό | ||
class RacingCar(val name: String = "λΆλΆμ΄", var position: Int = 0) { |
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.
νμ¬λ positionμ΄ privateνμ§ μκΈ° λλ¬Έμ μΈλΆμμ position κ°μ λ§μλλ‘ μμ ν μ μμ΄μ.
val car = RacingCar()
car.position = 123
μ΄λ»κ² κ°μ ν΄λ³Ό μ μμκΉμ?
https://kotlinlang.org/docs/properties.html#getters-and-setters
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.
"λΆλΆμ΄"λ λ무 κ·μ½μ§λ§(γ γ γ ) ν μ€νΈ νΈμμ±μ μν΄ λ§λ€μ΄μ§ κ°μ΄λ―λ‘ νλ‘λμ μ½λμ μΆκ°λκΈ°μλ μ ν©νμ§ μμ κ² κ°μμ.
assertThrows<IllegalArgumentException> { | ||
RacingCar("1234567") | ||
} | ||
assertThat(assertThrows<IllegalArgumentException> { RacingCar("1234567") }.message) |
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.
RacingCarμ position κ°μ μ΄κΈ°ννλ€λ κ²μ λͺ μμ μΌλ‘ λλ¬λ΄κΈ° μν΄ named argumentsλ₯Ό νμ©νμλ©΄ μ΄λ¨κΉμ?
RacingCar(position = "1234567")
μ΄ μΈμλ named argumentsλ₯Ό νμ©ν κ³³μ΄ μλμ? νλ‘μ νΈ μ λ°μ μΌλ‘ μ μ©λ μ μλ λ³κ²½μ¬νμΈ κ² κ°μμ!
"3, 0", | ||
"2, 0", | ||
) | ||
fun `Param κ°μ λ°λΌ μλμ°¨ κ·Έλ£Ήμ΄ μ΄λνλ€`( |
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.
ν μ€νΈλͺ μ ν΅ν΄ μ΄λ€ κ²μ ν μ€νΈνκ³ μ νλ κ²μ΄ μ λλ‘ λλ¬λμ§ μλ κ² κ°μμ. ν μ€νΈλͺ μ μμ±νμ€ λμλ
- κ²μ¦νκ³ μ νλ λ‘μ§μ λͺ ννκ² μ νκ³ (κ²μ¦μ΄ νμν λ‘μ§μ΄ λ κ° μ΄μμ΄λ©΄ νμμ λ°λΌ λ λ€λ₯Έ ν¨μλ‘ λΆν νλ€)
- κ·Έκ²μ ν¨μλͺ μΌλ‘ λλ¬λ΄λ³΄λ©΄ μ΄λ¨κΉμ?
μ΄μμ μΌλ‘λ κΈ°λ₯ μꡬ μ¬νμΌλ‘ μ 리νμ λ¬Έμμ μλ리μ€κ° κ·Έλλ‘ ν μ€νΈ μλ리μ€λ‘λ μ΄μ΄μ§λ©΄ μ’μ΅λλ€ π
"3, '---'", | ||
"5, '-----'", | ||
) | ||
fun `positionλ§λ€ -λ₯Ό λΆμΈλ€`( |
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.
λ€μ μꡬ μ¬νμ λ€μ ν λ² κ³ λ €ν΄λ³΄λ©΄ μ΄λ¨κΉμ~?
λͺ¨λ λ‘μ§μ λ¨μ ν μ€νΈλ₯Ό ꡬννλ€. λ¨, UI(System.out, System.in) λ‘μ§μ μ μΈ
ν΅μ¬ λ‘μ§μ ꡬννλ μ½λμ UIλ₯Ό λ΄λΉνλ λ‘μ§μ ꡬλΆνλ€.
UI λ‘μ§μ InputView, ResultViewμ κ°μ ν΄λμ€λ₯Ό μΆκ°ν΄ λΆλ¦¬νλ€.
μλ νμΈμ μνλ!
μ΄λ² μ€ν μ view/domainν΄λμ€μ μ± μλΆλ¦¬μ μ΄μ λ¨κ³μμ νΌλλ°± μ£Όμ ¨λ
리뷰 λ°νμΌλ‘ 볡μ΅νμ΅λλ€.
νλ©΄μ κ°μ¬μ€ μ¬μ λ³΄κ³ μλλ°, οΏ½οΏ½νμ€ν μ΄μ μ λ΄€μλλ λ€λ₯΄κ² λ€κ°μ€λκ±° κ°μμ. λ§μ§λ§ λ¨κ³λ νΌλλ°± μ λΆνλλ €μ!