Step2#232
Conversation
# Conflicts: # src/main/kotlin/minesweeper/README.md # src/main/kotlin/minesweeper/controller/GameController.kt # src/main/kotlin/minesweeper/domain/Block.kt # src/main/kotlin/minesweeper/domain/ExceptionReason.kt # src/main/kotlin/minesweeper/domain/MineSweeperBoard.kt # src/main/kotlin/minesweeper/domain/Point.kt # src/main/kotlin/minesweeper/view/ResultView.kt # src/main/kotlin/minesweeper/view/ResultViewImpl.kt # src/test/kotlin/minesweeper/domain/PointTest.kt
ohgillwhan
left a comment
There was a problem hiding this comment.
코드 잘 봤습니다. MimeSweeperBoard 테스트 코드도 부탁드려용!
| } catch (e: MineSweeperException) { | ||
| resultView.printKnownException(e) | ||
| null | ||
| } catch (e: Exception) { | ||
| resultView.printUnknownException(e) | ||
| null | ||
| } |
| @@ -4,14 +4,29 @@ sealed class Block { | |||
| abstract fun open() | |||
There was a problem hiding this comment.
열 수 있는 블록과 없는 블록을 나누는건 어떨까요?
TODO("Not yet implemented") 가 나와서 애매해지는거 같아요.
| _state = buildBoard(width, height).toMutableMap() | ||
| plantMines(mineCount) | ||
| _mineCount = countMine() | ||
| buildSafeBlock() |
There was a problem hiding this comment.
이 코드는 buildBoard를 할 때 같이 이뤄져야 하지 않나요?
| _state = buildBoard(width, height).toMutableMap() | ||
| plantMines(mineCount) | ||
| _mineCount = countMine() | ||
| buildSafeBlock() |
| val width = Random().nextInt(width) | ||
| val height = Random().nextInt(height) |
| private fun plusOrNull(x: Int, y: Int): Point? { | ||
| return try { | ||
| Point(this.x + x, this.y + y) | ||
| } catch (e: Exception) { |
There was a problem hiding this comment.
try catch로 로직을 수행하는게 조금 아쉽네요. 현재 객체에서 x, y 만큼 더 할 수 있는지 메서드를 만들어서 처리해보는건 어떨까요?
|
안녕하세요? |
| return gameBoard.state | ||
| fun run(): MineSweeperBoard? { | ||
| return try { | ||
| val gameBoard = setUp() |
|
|
||
| override fun compareTo(other: Point) = compareValuesBy(this, other, { it.y }, { it.x }) | ||
|
|
||
| private fun plusOrNull(x: Int, y: Int, maxX: Int, maxY: Int): Point? { |
| override fun open() { | ||
| TODO("Not yet implemented") | ||
| } |
There was a problem hiding this comment.
구현이 안될 메서드를 만들어야 하는건 조금 아쉽네요. Block을 세분화 해보는건 어떨까요?
|
|
||
|
|
| val userInputMineCount = 1 | ||
|
|
||
| val controller = | ||
| GameController(FakeInputView(userInputHeight, userInputWidth, userInputMineCount), ResultViewImpl()) |
There was a problem hiding this comment.
ResultViewImpl 보다 더 좋은 의미는 없을까요? ConsoleResultView 이런식으로요
|
|
||
| @Test | ||
| fun `0보다 작은 수는 생성될 수 없다`() { | ||
| val exception = org.junit.jupiter.api.assertThrows<MineSweeperException> { |
| val minePoints = strategy.createMines(width, height, plantingMineCount) | ||
| minePoints.forEach { | ||
| _state[it] = MineBlock() | ||
| } | ||
| _mineCount = countMine() | ||
| updateSafeBlock() |
There was a problem hiding this comment.
전략을 바꿀 수 있으니, 여러 장점이 있을것 같아요.
테스트코드에서 전략을 한개 만들어서, 그 전략만큼 지뢰가 잘 심겼는지 등 테스트 할 수 있겠죠? 나중에 게임 실행하면서 원하는 위치에 지뢰를 심고, 터트리는 등 테스트를 더욱 쉽게 가능할거에요.
|
안녕하세요?
|
안녕하세요.. 제가 뭔가 커밋을 잘못했는지 꼬였어요.
refactor: ResultView의 매직 리터럴 companion object로 이동
커밋부터 봐주시면 될것같아요.
오늘이 마지막 피드백 날짜라고 해서 진행하던 2단계를 부랴부랴 정리하고 PR 날립니다..