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(WordResult): 단어 결과는 단어 길이와 일치해야 합니다.
boradol committed Jun 17, 2024
commit 9299ecae2bda4fab4624a770e6c2c9735e7454ee
6 changes: 6 additions & 0 deletions src/main/kotlin/wordle/domain/WordResult.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package wordle.domain

import wordle.exception.WordleExceptionCode.WORD_RESULT_INVALID_LENGTH

data class WordResult(private val result: MutableList<LetterMatch> = MutableList(WORD_LENGTH) { LetterMatch.ABSENT }) {
init {
check(result.size == WORD_LENGTH) { WORD_RESULT_INVALID_LENGTH.message }
}

fun changeMatchType(
index: Int,
matchType: LetterMatch,
1 change: 1 addition & 0 deletions src/main/kotlin/wordle/exception/WordleExceptionCode.kt
Original file line number Diff line number Diff line change
@@ -8,4 +8,5 @@ enum class WordleExceptionCode(val message: String) {
WORD_IS_NOT_IN_DICTIONARY("Wordle Game에서 유효한 단어가 아닙니다."),
LETTER_INVALID_CHARACTER_TYPE("유효하지 않은 글자 형식입니다."),
TRY_COUNT_HAS_NOT_REMAINDER("시행 횟수는 0보다 작을 수 없습니다."),
WORD_RESULT_INVALID_LENGTH("단어 결과의 글자 일치 상태 목록들은 단어 길이인 ${WORD_LENGTH}와 일치해야 합니다."),
}
14 changes: 11 additions & 3 deletions src/test/kotlin/wordle/domain/WordResultTest.kt
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package wordle.domain

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

class WordResultTest {
@Test
fun `단어 결과는 글자 일치 상태 목록 없이 생성할 수 있다 - 모두 '불일치 상태'를 가진다`() {
fun `(성공) 단어 결과는 글자 일치 상태 목록 없이 생성할 수 있다 - 모두 '불일치 상태'를 가진다`() {
val wordResult = WordResult()

assertThat(wordResult).isEqualTo(MutableList(WORD_LENGTH) { LetterMatch.ABSENT }.toWordResult())
}

@Test
fun `해당 글자의 글자 일치 상태를 변경할 수 있다`() {
fun `(성공) 해당 글자의 글자 일치 상태를 변경할 수 있다`() {
val wordResult = WordResult()

wordResult.changeMatchType(0, LetterMatch.CORRECT)
@@ -32,7 +33,7 @@ class WordResultTest {
}

@Test
fun `해당 글자가 '완전 일치 상태'인지 확인한다`() {
fun `(성공) 해당 글자가 '완전 일치 상태'인지 확인한다`() {
val wordResult = WordResult()

wordResult.changeMatchType(1, LetterMatch.CORRECT)
@@ -42,6 +43,13 @@ class WordResultTest {
{ assertThat(wordResult.isCorrectMatchIndex(1)).isTrue() },
)
}

@Test
fun `(예외) 단어 결과 목록이 단어 길이와 일치헤야 한다`() {
assertThatThrownBy { WordResult(mutableListOf()) }
.isInstanceOf(IllegalStateException::class.java)
.hasMessage("단어 결과의 글자 일치 상태 목록들은 단어 길이인 ${WORD_LENGTH}와 일치해야 합니다.")
}
}

fun MutableList<LetterMatch>.toWordResult(): WordResult = WordResult(this)