-
Notifications
You must be signed in to change notification settings - Fork 204
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
๐ 4๋จ๊ณ - ์ง๋ขฐ ์ฐพ๊ธฐ(๋ฆฌํฉํฐ๋ง) #491
base: devtaebong
Are you sure you want to change the base?
Conversation
docs/step4.md
Outdated
- [ ] ํ๋ ์ด์์ ์ง๋ขฐ ์ ์ ์ด์์ผ๋ฉด ๊ฒ์์์ ํจ๋ฐฐํ๋ค. | ||
- [ ] ๋ชจ๋ ๋น ์ ์ ์ด์์ผ๋ฉด ๊ฒ์์์ ์น๋ฆฌํ๋ค. | ||
- [ ] ์ ๋ ฅํ ์ ์ ์ง๋ขฐ๊ฐ ์๋ค๋ฉด, ์ฐ๊ฒฐ๋ empty์ ๋ชจ๋ Open | ||
- [ ] close ๋ ์ ์ C๋ฅผ ์ถ๋ ฅ | ||
- [ ] open ๋ ์ ์ ์ธ์ ํ ์ง๋ขฐ ๊ฐ์๋ฅผ ์ถ๋ ฅ |
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.
์ฒดํฌ๊ฐ ์๋์ด์๋ค์๐ฅฒ
์ปค๋ฐ์ ๋ค์ ํ๋ฉด ๋ฆฌ๋ทฐ ์์ฒญ์ ๋ค์ ๋๋ ค์ผํ๋๊ฑธ๋ก ์๊ณ ์๋๋ฐ, ์์ ํด๋๊ณ ๋ค์ ํผ๋๋ฐฑ์ ๋ฐ์ํ๊ฒ ์ต๋๋ค!
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.
ํํ๋ 4๋จ๊ณ๋ ์ ๊ตฌํํด์ฃผ์
จ๋ค์ ๐๐ฏ
ํฌ๊ฒ ํผ๋๋ฐฑ ๋๋ฆด ๋ด์ฉ์ ์์์ผ๋ ์ถ๊ฐ๋ก ๋ช๋ช ์ฝ๋ฉํธ ๋จ๊ฒจ๋์์ต๋๋ค. ๐
ํ์ธํด์ ๋ฐ์ ๋ถํ๋๋ฆด๊ฒ์.
์๋ง ๋ค์ ๋ฆฌ๋ทฐ ์์ฒญ์์๋ ๋จธ์ง๊ฐ ๋์ง ์์๊น ์ถ๋ค์. ๐
๋ง์ง๋ง๊น์ง ํ์ดํ
์
๋๋ค. ๐ช
@@ -25,12 +24,23 @@ class MineSweeperController { | |||
private fun gameLoop(mineBoard: MineBoard) { | |||
val mineSweeperGame = MineSweeperGame(mineBoard) | |||
while (mineSweeperGame.isContinueGame()) { | |||
val coordinate = InputView.askMineCoordinate() | |||
mineSweeperGame.openAdjacentCell(coordinate) | |||
val requestOpenCoordinate = InputView.askMineCoordinate() |
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.
View๊ฐ Model ๊ฐ์ฒด๋ฅผ ์ง์ ์์กดํ๊ณ ์๋ ๊ฒ์ผ๋ก ๋ณด์ฌ์. (InputView์ ๊ฒฐ๊ณผ๋ฌผ์ด Coordinate)
View์์๋ ๋จ์ํ ์์ ๊ฐ์ ๋ฐ์๋ค์ด๊ณ , Model๋ก์ ๋ณํ์ Controller ๊ณ์ธต์์ ํด์ฃผ๋ฉด M, V ๊ฐ์ ์์กด์ฑ์ ์ ๊ฑฐํ ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค.
src/main/kotlin/domain/Cells.kt
Outdated
fun isAllEmptyCellsOpened(): Boolean { | ||
return cells | ||
.filter { it.isMineCell().not() } | ||
.all { it.status == CellStatus.OPEN } |
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.
it.isOpen()
๊ณผ ๊ฐ์ด ๋ฉ์์ง๋ฅผ ๋ณด๋ด๋ณผ ์ ์์ ๊ฒ ๊ฐ์์. ๐
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.
์ด ๋ถ๋ถ์ Cell.isOpened
๋ฉ์๋๋ ๋ง๋์ ๊ฒ ๊ฐ์๋ฐ, ํด๋น ๋ฉ์๋๋ฅผ ํธ์ถํ๋๋ก ๋ณ๊ฒฝํ์๋ ๋ถ๋ถ์ ๋๋ฝ๋ ๊ฒ ๊ฐ์์! ๐
src/main/kotlin/domain/Cells.kt
Outdated
} | ||
|
||
fun countOpenedEmptyCells(): Int { | ||
return emptyCells().count { it.status == CellStatus.OPEN } | ||
fun getBoardWidth(): Col { |
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.
width ๋ผ๊ฑฐ๋ height์ ๊ฒฝ์ฐ ์ฝ๊ธฐ ์ ์ฉ ํ๋กํผํฐ๋ก ๋๋ ๊ฒ๋ ๊ด์ฐฎ์ง ์์๊น์? ๐
val width: Int
get() = cells.maxBy { it.coordinate.col }.coordinate.col
val height: Int
get() = cells.maxBy { it.coordinate.row }.coordinate.row
|
||
fun getCell(coordinate: Coordinate): Cell = cells.get(coordinate) | ||
|
||
fun openCell(coordinate: Coordinate) = cells.get(coordinate).open() |
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.
openCell, countAdjacentMines ๋ฉ์๋์ ๋ํ ํ ์คํธ๋ ์ถ๊ฐํด์ฃผ์๋ฉด ์ข์ ๊ฒ ๊ฐ์์. ๐
๊ฒฝ๋ก๋ ์๋
ํ์ธ์! |
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.
ํํ๋ ๋ง์ง๋ง ๋ฆฌํฉํฐ๋ง ๋ฏธ์
ํผ๋๋ฐฑ๋ ์ ๋ฐ์ํด์ฃผ์
จ์ต๋๋ค. ๐๐ฏ
์ด๋ก์จ ๋ง์ง๋ง ๋ฏธ์
์ธ ์ง๋ขฐ ์ฐพ๊ธฐ ๋ฏธ์
๋ ์ด๋ง ์ข
๋ฃํ๋๋กํ๊ฒ ์ต๋๋ค.
๋ฏธ์
์งํํ์๋๋ผ ๊ณ ์ ๋ง์ผ์
จ์ต๋๋ค. ๐
src/main/kotlin/domain/Cells.kt
Outdated
fun isAllEmptyCellsOpened(): Boolean { | ||
return cells | ||
.filter { it.isMineCell().not() } | ||
.all { it.status == CellStatus.OPEN } |
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.
์ด ๋ถ๋ถ์ Cell.isOpened
๋ฉ์๋๋ ๋ง๋์ ๊ฒ ๊ฐ์๋ฐ, ํด๋น ๋ฉ์๋๋ฅผ ํธ์ถํ๋๋ก ๋ณ๊ฒฝํ์๋ ๋ถ๋ถ์ ๋๋ฝ๋ ๊ฒ ๊ฐ์์! ๐
} | ||
return EmptyCell(coordinate) | ||
fun of(mineCellGenerator: MineCellGenerator): Cells { | ||
val mineCells = mineCellGenerator.execute() |
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.
execute ๋ฉ์๋์ ๊ฒฐ๊ณผ๋ฅผ Set์ผ๋ก ํ๊ธฐ๋ณด๋ค๋ List๋ก ๋ด๋ ค์ฃผ๋ฉด ์ด๋จ๊น์? ๐ค
์ค๋ณต ์ ๊ฑฐ๊ฐ ๊ฑฑ์ ๋๋ค๋ฉด execute ๋ฉ์๋ ์์์ distinct
๋ฅผ ํ๋ฒ ์ํํด์ฃผ๋ฉด ๋ ๊ฒ ๊ฐ์์์. ๐
๊ฒฝ๋ก๋ ์๋ ํ์ธ์!
"์ฒ ์ ํ๊ฒ TDD๋ก ์ฌ๊ตฌํํด ๋ณธ๋ค."๋ผ๋ ์๊ตฌ์ฌํญ์ ๋ฐ์ํ์ฌ ๋ฏธ์ ์ ์งํํ์ต๋๋ค. ๐
์ถ๊ฐ์ ์ผ๋ก, getter๋ฅผ ์ฌ์ฉํ์ง ์๊ณ ๊ฐ์ฒด ๊ฐ ๋ฉ์์ง๋ฅผ ์ ๋ฌํ๋ ๋ฐฉ์์ผ๋ก ์ค๊ณ๋ฅผ ๊ฐ์ ํ๋ ค๊ณ ๋ ธ๋ ฅํ์ต๋๋ค!
์ด๋ฒ ๋ฆฌ๋ทฐ๋ ์ ๋ถํ๋๋ฆฝ๋๋ค! ๐โโ๏ธ
๊ฐ์ฌํฉ๋๋ค. ๐