Skip to content
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

Open
wants to merge 34 commits into
base: devtaebong
Choose a base branch
from

Conversation

devtaebong
Copy link

๊ฒฝ๋ก๋‹˜ ์•ˆ๋…•ํ•˜์„ธ์š”!
"์ฒ ์ €ํ•˜๊ฒŒ TDD๋กœ ์žฌ๊ตฌํ˜„ํ•ด ๋ณธ๋‹ค."๋ผ๋Š” ์š”๊ตฌ์‚ฌํ•ญ์„ ๋ฐ˜์˜ํ•˜์—ฌ ๋ฏธ์…˜์„ ์ง„ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค. ๐Ÿ˜ƒ
์ถ”๊ฐ€์ ์œผ๋กœ, getter๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ๊ฐ์ฒด ๊ฐ„ ๋ฉ”์‹œ์ง€๋ฅผ ์ „๋‹ฌํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ์„ค๊ณ„๋ฅผ ๊ฐœ์„ ํ•˜๋ ค๊ณ  ๋…ธ๋ ฅํ–ˆ์Šต๋‹ˆ๋‹ค!

์ด๋ฒˆ ๋ฆฌ๋ทฐ๋„ ์ž˜ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค! ๐Ÿ™‡โ€โ™‚๏ธ
๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ๐Ÿ˜Š

docs/step4.md Outdated
Comment on lines 16 to 20
- [ ] ํ•˜๋‚˜ ์ด์ƒ์˜ ์ง€๋ขฐ ์…€์„ ์—ด์—ˆ์œผ๋ฉด ๊ฒŒ์ž„์—์„œ ํŒจ๋ฐฐํ•œ๋‹ค.
- [ ] ๋ชจ๋“  ๋นˆ ์…€์„ ์—ด์—ˆ์œผ๋ฉด ๊ฒŒ์ž„์—์„œ ์Šน๋ฆฌํ•œ๋‹ค.
- [ ] ์ž…๋ ฅํ•œ ์…€์— ์ง€๋ขฐ๊ฐ€ ์—†๋‹ค๋ฉด, ์—ฐ๊ฒฐ๋œ empty์„ ๋ชจ๋‘ Open
- [ ] close ๋œ ์…€์€ C๋ฅผ ์ถœ๋ ฅ
- [ ] open ๋œ ์…€์€ ์ธ์ ‘ํ•œ ์ง€๋ขฐ ๊ฐœ์ˆ˜๋ฅผ ์ถœ๋ ฅ
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ฒดํฌ๊ฐ€ ์•ˆ๋˜์–ด์žˆ๋„ค์š”๐Ÿฅฒ
์ปค๋ฐ‹์„ ๋‹ค์‹œ ํ•˜๋ฉด ๋ฆฌ๋ทฐ ์š”์ฒญ์„ ๋‹ค์‹œ ๋“œ๋ ค์•ผํ•˜๋Š”๊ฑธ๋กœ ์•Œ๊ณ ์žˆ๋Š”๋ฐ, ์ˆ˜์ •ํ•ด๋†“๊ณ  ๋‹ค์Œ ํ”ผ๋“œ๋ฐฑ์— ๋ฐ˜์˜ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!

Copy link

@Rok93 Rok93 left a 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()
Copy link

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 ๊ฐ„์˜ ์˜์กด์„ฑ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

fun isAllEmptyCellsOpened(): Boolean {
return cells
.filter { it.isMineCell().not() }
.all { it.status == CellStatus.OPEN }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it.isOpen()๊ณผ ๊ฐ™์ด ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด๋ณผ ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์•„์š”. ๐Ÿ˜ƒ

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด ๋ถ€๋ถ„์€ Cell.isOpened ๋ฉ”์„œ๋“œ๋Š” ๋งŒ๋“œ์‹  ๊ฒƒ ๊ฐ™์€๋ฐ, ํ•ด๋‹น ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•˜๋„๋ก ๋ณ€๊ฒฝํ•˜์‹œ๋Š” ๋ถ€๋ถ„์€ ๋ˆ„๋ฝ๋œ ๊ฒƒ ๊ฐ™์•„์š”! ๐Ÿ‘€

}

fun countOpenedEmptyCells(): Int {
return emptyCells().count { it.status == CellStatus.OPEN }
fun getBoardWidth(): Col {
Copy link

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()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

openCell, countAdjacentMines ๋ฉ”์„œ๋“œ์— ๋Œ€ํ•œ ํ…Œ์ŠคํŠธ๋„ ์ถ”๊ฐ€ํ•ด์ฃผ์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”. ๐Ÿ˜ƒ

@devtaebong
Copy link
Author

๊ฒฝ๋ก๋‹˜ ์•ˆ๋…•ํ•˜์„ธ์š”!
๊ผผ๊ผผํ•œ ํ”ผ๋“œ๋ฐฑ ๋‹ค์‹œํ•œ๋ฒˆ ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค ๐Ÿ™‡๐Ÿปโ€โ™‚๏ธ

Copy link

@Rok93 Rok93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํƒœํ˜„๋‹˜ ๋งˆ์ง€๋ง‰ ๋ฆฌํŒฉํ„ฐ๋ง ๋ฏธ์…˜ ํ”ผ๋“œ๋ฐฑ๋„ ์ž˜ ๋ฐ˜์˜ํ•ด์ฃผ์…จ์Šต๋‹ˆ๋‹ค. ๐Ÿ‘๐Ÿ’ฏ
์ด๋กœ์จ ๋งˆ์ง€๋ง‰ ๋ฏธ์…˜์ธ ์ง€๋ขฐ ์ฐพ๊ธฐ ๋ฏธ์…˜๋„ ์ด๋งŒ ์ข…๋ฃŒํ•˜๋„๋กํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
๋ฏธ์…˜ ์ง„ํ–‰ํ•˜์‹œ๋Š๋ผ ๊ณ ์ƒ ๋งŽ์œผ์…จ์Šต๋‹ˆ๋‹ค. ๐Ÿ™

fun isAllEmptyCellsOpened(): Boolean {
return cells
.filter { it.isMineCell().not() }
.all { it.status == CellStatus.OPEN }
Copy link

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()
Copy link

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๋ฅผ ํ•œ๋ฒˆ ์ˆ˜ํ–‰ํ•ด์ฃผ๋ฉด ๋  ๊ฒƒ ๊ฐ™์•„์„œ์š”. ๐Ÿ˜ƒ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants