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

[둘리] 1, 2단계 오목 제출합니다. #26

Merged
merged 18 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
fe3ce07
docs: 오목 기능 목록 작성
tmdgh1592 Mar 14, 2023
ca4182c
feat: 1부터 15 위치를 가진 오목알 클래스 구현
tmdgh1592 Mar 14, 2023
e13e7da
feat: 중복 오목알 처리를 위한 오목알 일급 컬렉션 구현
tmdgh1592 Mar 14, 2023
fa5e2b9
docs: .gitkeep 파일 제거
tmdgh1592 Mar 14, 2023
0c398fd
feat: 오목알을 놓은 플레이어가 게임에서 이겼는지 확인하는 기능 구현
tmdgh1592 Mar 14, 2023
190d007
feat: 사용자가 오목알을 놓았을 때 상태를 반환하는 기능 구현
tmdgh1592 Mar 14, 2023
9d0c276
feat: 오목판에 돌을 올려놓는 기능 구현
tmdgh1592 Mar 15, 2023
606cfcf
feat: 플레이어의 오목알을 놓는 턴을 바꾸는 기능 구현
tmdgh1592 Mar 15, 2023
f96746e
refactor: 돌을 놓으면 새로운 상태를 가진 플레이어 반환하는 기능 구현
tmdgh1592 Mar 15, 2023
e5e8ce4
feat: 플레이어가 놓은 마지막 돌을 리턴하는 기능 구현
tmdgh1592 Mar 15, 2023
c472a31
refactor: 오목알을 놓을 수 있는지 확인하는 함수를 Players 클래스로 이동
tmdgh1592 Mar 15, 2023
f4f1b15
feat: 오목 게임 진행하는 기능 구현
tmdgh1592 Mar 15, 2023
28bb0cd
feat: 오목 게임 입력, 출력 화면 구현
tmdgh1592 Mar 15, 2023
f37f93b
feat: 오목 컨트롤러 구현
tmdgh1592 Mar 15, 2023
b1fcb5b
refactor: 도메인 패키지 분리
tmdgh1592 Mar 15, 2023
11b2666
fix: 중간에 오목알을 뒀을 때 승리 판정하지 않는 오류 수정
tmdgh1592 Mar 16, 2023
a0166e0
feat: 렌주룰 기능 추가 (미완성)
tmdgh1592 Mar 16, 2023
7eb0bc9
feat: 렌주룰 적용 (완성)
tmdgh1592 Mar 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: 1부터 15 위치를 가진 오목알 클래스 구현
  • Loading branch information
tmdgh1592 committed Mar 14, 2023
commit ca4182c3b08411dd22029aa6097378fbd5d5edf9
5 changes: 3 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

### Domain
- [ ] 흑돌이 먼저 시작한다.
- [ ] 오목알은 자신의 위치를 알고 있다.
- [ ] `x, y` 위치는 `1부터 15`로 제한된다.
- [x] 오목알은 자신의 위치를 알고 있다.
- [x] `x, y` 위치는 `1부터 15`로 제한된다.
- [ ] 중복되는 위치의 오목알을 가질 수 없다.
- [ ] 오목판의 크기는 `15 x 15`이다.
- [ ] 사용자는 오목알을 놓는다.
- [ ] 사용자는 게임에서 이겼는지 확인한다.
Expand Down
13 changes: 13 additions & 0 deletions src/main/kotlin/Position.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
data class Position(val x: Int, val y: Int) {
init {
require(x in MIN_BOUND..MAX_BOUND) { X_OUT_OF_RANGE_ERROR_MESSAGE }
require(y in MIN_BOUND..MAX_BOUND) { Y_OUT_OF_RANGE_ERROR_MESSAGE }
}

companion object {
const val MIN_BOUND = 1
const val MAX_BOUND = 15
private const val X_OUT_OF_RANGE_ERROR_MESSAGE = "x의 범위는 ${MIN_BOUND}부터 ${MAX_BOUND}입니다"
private const val Y_OUT_OF_RANGE_ERROR_MESSAGE = "y의 범위는 ${MIN_BOUND}부터 ${MAX_BOUND}입니다"
}
}
8 changes: 8 additions & 0 deletions src/main/kotlin/Stone.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Stone private constructor(val position: Position) {
companion object {
private val POSITION_RANGE = (Position.MIN_BOUND..Position.MAX_BOUND)
private val STONES = POSITION_RANGE.map { x -> POSITION_RANGE.map { y -> Stone(Position(x, y)) } }

fun of(x: Int, y: Int) = STONES[x][y]
}
}
29 changes: 29 additions & 0 deletions src/test/kotlin/PositionTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertAll
import org.junit.jupiter.api.assertThrows

class PositionTest {
@Test
fun `오목알의 위치는 범위가 1부터 15인 x, y를 가지고 있다`() {
val position = Position(10, 10)
assertAll({
assertThat(position.x).isEqualTo(10)
assertThat(position.y).isEqualTo(10)
})
}

@Test
fun `x의 범위가 1부터 15 사이가 아니면 에러가 발생한다`() {
assertThrows<IllegalArgumentException> {
Position(16, 10)
}
}

@Test
fun `y의 범위가 1부터 15 사이가 아니면 에러가 발생한다`() {
assertThrows<IllegalArgumentException> {
Position(10, 16)
}
}
}
10 changes: 10 additions & 0 deletions src/test/kotlin/StoneTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@


class StoneTest {
// @Test
// fun `오목알은 자신의 위치를 알고 있다`() {
// val stone = Stone("H", 10)
// assertThat(stone.x).isEqualTo("H")
// assertThat(stone.y).isEqualTo(10)
// }
}