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

feat: step2 기능구현 #376

Open
wants to merge 1 commit into
base: hyunjaesung
Choose a base branch
from

Conversation

hyunjaesung
Copy link

안녕하세요 간단하게 구현했습니다!

Copy link

@sah3122 sah3122 left a comment

Choose a reason for hiding this comment

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

지뢰 개수 구현 잘해주셨습니다 👍
몇가지 생각거리를 남겨두었는데 확인 부탁드려요 🙏

Comment on lines +31 to +32
for (i in -1..1) {
for (j in -1..1) {
Copy link

Choose a reason for hiding this comment

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

반복문을 사용하여 주변 지뢰를 찾는것도 좋지만 이번 미션을 진행하며 작은 단위의 클래스를 도출하는 연습을 하는것을 권장 드립니다.
방향을 나타내는 클래스를 정의하여 주변의 지뢰를 찾아보는건 어떨까요 ?

class MinePoint(val isMine: Boolean)


class MinePoint(val isMine: Boolean, val mineCountNear: Int = 0)
Copy link

Choose a reason for hiding this comment

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

MinePoint 클래스만 활용하여 지뢰, 지뢰가 아닌 위치를 나타내기보단 추상화를 도입하여 보는것을 권장 드립니다 😄

Comment on lines +23 to +27
_map.forEachIndexed { col, colList ->
colList.forEachIndexed { row, minePoint ->
_map[col][row]= MinePoint(minePoint.isMine, getNearMineCount(col, row))
}
}
Copy link

Choose a reason for hiding this comment

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

메서드로 분리하여 가독성을 높일수 있을것 같아요 😄

@@ -10,12 +13,33 @@ class GameMap(height: Int, width: Int, mineCount: Int) {
val mines = positions.take(mineCount)

// 맵 생성
map = List(height) { col ->
List(width) { row ->
_map = MutableList(height) { col ->
Copy link

Choose a reason for hiding this comment

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

_map 객체를 backing property 로 정의하지않고 init block에서만 선언해도 될것 같은데 어떻게 생각하시나요 ?

@@ -1,7 +1,10 @@
package model

class GameMap(height: Int, width: Int, mineCount: Int) {
Copy link

Choose a reason for hiding this comment

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

추가된 요구사항을 검증할수 있는 테스트 코드를 작성해보세요 😄

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.

None yet

3 participants