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

[Wordle] 돌쓰팀(보라돌) 미션 제출합니다. #21

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e715878
docs(README.md): 진행 요구 사항 작성
boradol Jun 16, 2024
50d1cf4
docs(README.md): 프로그래밍 요구 사항 작성
boradol Jun 16, 2024
59f7a4e
docs(README.md): 프로그래밍 요구사항 위치 변경
boradol Jun 16, 2024
8013a33
docs(README.md): 기능 요구 사항에 용어 정리와 기능 목록 항목 추가
boradol Jun 16, 2024
c5b1d44
docs(README.md): 용어정리
boradol Jun 16, 2024
54fe090
docs(README.md): 기능목록
boradol Jun 16, 2024
770346b
chore(.gitkeep): 불필요한 gitkeep 파일 제거
boradol Jun 17, 2024
5c26467
build: 코틀린 버전 1.9.0 -> 1.9.23
boradol Jun 17, 2024
4cc4c99
feat(Word): 문자열을 입력받아 단어를 만들 수 있다.
boradol Jun 17, 2024
a931257
feat(Word): 단어는 사전에 있는 단어이어야 한다.
boradol Jun 17, 2024
caeeff9
feat(ExceptionCode): Wordle의 에러 메시지를 관리한다.
boradol Jun 17, 2024
1cb3148
feat(Letter): 유효한 글자를 생성할 수 있다.
boradol Jun 17, 2024
2a3c133
feat(Letter): 일치 표시 기호가 들어간 글자로 변경할 수 있다.
boradol Jun 17, 2024
3e75764
feat(Word): 단어는 여러 개의 글자로 이루어진다.
boradol Jun 17, 2024
f328f65
refactor(DictionaryFileLoader): ClassLoader 이용하여 words.txt 파일 읽기
boradol Jun 17, 2024
798afda
refactor(Dictionary): 사전에 포함된 문자열인지 확인할 수 있다.
boradol Jun 17, 2024
add6622
feat(Dictionary): 사전 단어 목록의 인덱스로 한 문자열을 받을 수 있다.
boradol Jun 17, 2024
7b2a40e
chore : 테스트 패키지 이동 -> domain -> wordle.domain
boradol Jun 17, 2024
44680bd
feat(TodayWord): 오늘의 단어를 생성한다.
boradol Jun 17, 2024
24412d9
feat(AnswerWord): 답안 단어를 생성한다
boradol Jun 17, 2024
86967c2
feat(InputView, OutputView): 초기 입출력을 콘솔에 나타낸다.
boradol Jun 17, 2024
075025b
feat(Application, WordleGameController): 프로그램 실행 시작 구현
boradol Jun 17, 2024
64e58c2
feat(WordleGame): WordleGame 반복 수행 로직 초기 구현
boradol Jun 17, 2024
a64c965
feat(WordleGameLogic): 게임 로직을 통해 여러가지 상황들을 비교할 수 있다.
boradol Jun 17, 2024
8838156
feat(WordResult): 단어 결과는 글자 일치 여부 목록을 가지며, 단어 결과를 반환한다.
boradol Jun 17, 2024
6293b08
feat(WordComparator): 단어 비교기를 구현한다.
boradol Jun 17, 2024
bda9855
feat(TryCount): 워들 게임에서 시도 가능 횟수를 관리한다.
boradol Jun 17, 2024
9299eca
feat(WordResult): 단어 결과는 단어 길이와 일치해야 합니다.
boradol Jun 17, 2024
9a81038
feat(WordResults): 단어 결과 목록은 단어 결과들과 시도횟수를 관리한다.
boradol Jun 17, 2024
30850a7
feat(OutputView): 단어 출력
boradol Jun 17, 2024
51480af
feat(WordleGame): WordleGame을 할 수 있다.
boradol Jun 17, 2024
13225f6
refactor : PR 올리기 전 코드 수정
boradol Jun 17, 2024
b2c51db
docs(README.md): 프로그래밍 요구사항 체크하기
boradol Jun 17, 2024
4a4381f
refactor(Letter): import 수정
boradol Jun 18, 2024
8f462f7
refactor(WordleGame): 불필요한 파라미터 지우기
boradol Jun 18, 2024
e879694
refactor(WordComparator): 표시하는 문자와 답안문자를 구분하는 이름 짓기, 함수 이름 수정
boradol Jun 18, 2024
8a0dcb9
test(WordResults): 게임 계속여부와 성공여부에 따른 테스트코드 추가
boradol Jun 18, 2024
c15c888
refactor(OutputView): 하드코딩된 부분 변수로 추출 및 함수명 등 리팩토링
boradol Jun 18, 2024
2aba793
refactor(WordleGameTest): 인덴트와 변수 리팩토링
boradol Jun 18, 2024
1c428d7
refactor(Letter): private 함수 삭제
boradol Jun 26, 2024
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(WordResults): 단어 결과 목록은 단어 결과들과 시도횟수를 관리한다.
1. 단어결과를 추가하여 게임의 진행여부와 게임 성공여부를 판단할 수 있다.
boradol committed Jun 17, 2024
commit 9a81038ba1048e08777a987692b5c0bcbd0e1457
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -251,10 +251,10 @@ spill
- [x] 처음에 생성할 때, 글자 일치 상태는 불일치 상태이다.
- [x] 해당 글자의 글자 일치 상태를 변경할 수 있다.
- [x] 해당 글자가 '완전 일치 상태'인지 확인한다.
- [ ] 모든 글자 일치 상태가 '완전 일치 상태'이면, 해당 단어는 오늘의 단어와 같다.(게임 성공 여부가 된다)
- [x] 모든 글자 일치 상태가 '완전 일치 상태'이면, 해당 단어는 오늘의 단어와 같다.(게임 성공 여부가 된다)

#### 단어 결과 목록(Word Results)
- [ ] 단어결과와 시도횟수를 가진다. 이때, 단어결과 목록은 빈 목록이고, 시도한 횟수는 0이다.
- [ ] 단어 결과를 추가하면, 시도횟수는 1회 증가한다.
- [ ] 단어 결과 목록에서 단어 결과가 성공인 상태가 추가되면 게임은 성공한다.
- [ ] 단어 결과 목록에서 아직 게임 성공하지 못하고 시도 가능 횟수가 1 이상이면 게임을 계속할 수 있다.
- [x] 단어결과와 시도횟수를 가진다. 이때, 단어결과 목록은 빈 목록이고, 시도한 횟수는 0이다.
- [x] 단어 결과를 추가하면, 시도횟수는 1회 증가한다.
- [x] 단어 결과 목록에서 단어 결과가 성공인 상태가 추가되면 게임은 성공한다.
- [x] 단어 결과 목록에서 아직 게임 성공하지 못하고 시도 가능 횟수가 1 이상이면 게임을 계속할 수 있다.
4 changes: 4 additions & 0 deletions src/main/kotlin/wordle/domain/WordResult.kt
Original file line number Diff line number Diff line change
@@ -15,4 +15,8 @@ data class WordResult(private val result: MutableList<LetterMatch> = MutableList
}

fun isCorrectMatchIndex(index: Int): Boolean = result[index] == LetterMatch.CORRECT

fun isSuccessGame() = result.all { matchType -> matchType == LetterMatch.CORRECT }

fun matches(): List<LetterMatch> = result.toList()
}
19 changes: 19 additions & 0 deletions src/main/kotlin/wordle/domain/WordResults.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package wordle.domain

class WordResults(
private val results: MutableList<WordResult> = mutableListOf(),
private val tryCount: TryCount = TryCount(),
) {
val attemptCount get() = tryCount.attempts

fun addResults(result: WordResult) {
tryCount.minus()
results.add(result)
}

fun isContinuousGame(): Boolean = !isSuccessGame() && tryCount.isRemainder()

fun isSuccessGame(): Boolean = results.any(WordResult::isSuccessGame)

fun wordResults(): List<List<LetterMatch>> = results.map(WordResult::matches)
}
45 changes: 45 additions & 0 deletions src/test/kotlin/wordle/domain/WordResultsTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package wordle.domain

import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Assertions.assertAll
import org.junit.jupiter.api.Test

class WordResultsTest {
@Test
fun `(성공) 단어 결과 목록은 빈 단어 결과 목록과 시도한 횟수가 0이다`() {
val actual = WordResults()

assertAll(
{ assertThat(actual.wordResults()).hasSize(0) },
{ assertThat(actual.attemptCount).isZero() },
)
}

@Test
fun `(성공) 단어 결과 목록은 단어 결과를 추가하고, 시도횟수가 1회 증가한다`() {
val wordResults = WordResults()

wordResults.addResults(WordResult())

assertAll(
{ assertThat(wordResults.wordResults()).hasSize(1) },
{ assertThat(wordResults.attemptCount).isEqualTo(1) },
)
}

@Test
fun `(성공) 단어 결과 목록 상태가 게임을 계속 진행할 수 있는 상태인지 반환한다`() {
val wordResults = WordResults()
wordResults.addResults(WordResult())

assertThat(wordResults.isContinuousGame()).isTrue()
}

@Test
fun `(성공) 단어 맞추기에 성공한 경우 true 를 반환한다`() {
val wordResults = WordResults()
wordResults.addResults(WordResult(MutableList(WORD_LENGTH) { LetterMatch.CORRECT }))

assertThat(wordResults.isSuccessGame()).isTrue()
}
}