-
Notifications
You must be signed in to change notification settings - Fork 35
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] 제로(공재호) 미션 제출합니다. #7
base: main
Are you sure you want to change the base?
Conversation
fun contains(spell: Char): Boolean = value.contains(spell) | ||
|
||
companion object { | ||
private const val SIZE = 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 이걸 클래스 안에서 companion object
로 설정할지 고민하다가
저 같은 경우는 이 클래스 파일에서 전역변수로 설정했는데
제로는 어떤게 더 적절하다고 생각하시나요?
...
const val WORD_SIZE = 5
class Words {...}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
음... companion object
의 경우 싱글턴
이며 클래스당 1개만 구현할 수 있기때문에 명시적으로 이 곳
에서 관리할 것이다라는 것을 알 수 있을 것 같아요.
두 가지의 큰 차이점은 모르겠어요. 공부해봐야겠습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 companion object
의 정체가 뭘까 좀 공부를 해봐야겠어요. 현재는 뭔가 자바의 static
처럼 쓰고 있는데 그게 맞나라는 생각도 드네요 ㅋㅋ
저도 아직 다 읽지는 않았는데 도움이 될까 싶어서 찾은 글 하나 링크로 남겨놓겠습니다 :)
https://www.bsidesoft.com/8187
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 링크 접속이 안되네요! ㅠ_ㅠ
저도 찾아봤는데 공유해봅니다!
https://stackoverflow.com/questions/49969319/kotlin-difference-between-constant-in-companion-object-and-top-level
class WordsResponse(val path: String) { | ||
|
||
val words: List<Word> | ||
get() = getWords(path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val words: List<Word> = getWords(path)
저는 이런식으로 초기화해서 사용했던거 같은데(이런것도 초기화라고 부를 수 있을지 모르겠지만🤔)
이런식으로 하는 거하고 어떤차이가 있는건가요?😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 같은 것으로 알고 있어요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
둘 중에 어떤 표현방식을 선택해야 할지 고민이되네요🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
import java.io.File | ||
|
||
class WordsResponse(val path: String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class WordsResponse(private val path: String) {
혹시 현재 상황에서 이거 private 으로 선언해도 괜찮지 않나요?🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수정했습니다 👍
|
||
private val _gameResult = mutableListOf<Tiles>() | ||
|
||
val gameResult: List<Tiles> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val gameResult: List<Tiles> = _gameResult
여기도 이런식으로 하는건 어떻게 생각하시는지 궁금해요!😀
class Words(private val words: List<Word>) { | ||
|
||
fun findAnswer(current: LocalDate): Word { | ||
val answerIndex = ChronoUnit.DAYS.between(BASE_DATE, current) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분 도움 많이 받았습니다 👍
그런데 이부분 % words.txt의 단어 개수
연산도 해줘야 하는거 아닌가요?
혹시 제가 못본걸까요😲
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
맞아요ㅠ 연산 추가해주어야해요! 왜인지 잊어버렸군요 ㅎㅎㅎ,,
} | ||
|
||
private fun matchSpell(spell: Char, index: Int): Tile { | ||
val answer = words.findAnswer(date) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
matchResult
의 반복문 안에서 matchSpell
메서드가 실행될 때 마다 findAnswer
메서드가 실행되는걸 어떻게 생각하시나요!? 저도 이 부분 고민하다가 결국에는 Game
객체가 오늘의 정답을 매개변수로 입력받으면서 생성되는 방향을 짰는데 제로의 생각이 궁금하네요! 😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그 방법이 더 좋을 것 같아요!!! 😀😀😀
play(game, gameResult) | ||
} | ||
|
||
private fun play(game: Game, gameResult: GameResult) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
play
라는 책임이 도메인의 책임처럼 느껴져서 저는 Game
객체가 가지도록 했는데 제로는 어떻게 생각하시나요? 😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수업 때 잠깐 제로랑 얘기했던 부분인데
역시 책임을 어떻게 할당할지에 대한 고민은 항상 어려운 것 같네요 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그쵸 ㅠㅠ 역할과 책임 분리가 가장 어려운것같아요
import wordle.domain.Tile.YELLOW | ||
import java.time.LocalDate | ||
|
||
internal class GameTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코테스트 적용하신 부분 잘봤어요! 멋지네요! 저도 시도해봐야겠습니다👍
안녕하세요 제로! 부족한 실력이지만 제로가 구현하신 코드 보면서 코멘트를 한번 달아봤습니다😂 저는 코틀린하고 이제 친해질랑 말랑하는거 같은데 제로 코드 보면서 또 한번 배웠네요 :) 코멘트 작성한 부분들은 단순히 저와 다른 부분들에 대해서 제로의 생각이 궁금하고 또 여쭤보고 싶어서 달았습니다! 다음에 같이 이 부분들에 대해서 얘기 해봐도 좋을것 같네요! 감사합니다 제로😀 |
안녕하세요 제로 :) |
Wordle 미션 제출합니다