[4기][3주차] Wordle 과제 제출 - 분수#25
Conversation
MoonHKLee
left a comment
There was a problem hiding this comment.
너무 좋은 코드를 작성하셔서 보고 많이 배웠습니다.
개인적인 의견 코멘트로 남겼으니 확인 부탁드립니다.🙏
| /*@DisplayName("그린 1개, 노란색 1개, 회색 3개인 답안을 비교한다.") | ||
| @Test | ||
| void test01() { | ||
| CorrectAnswer correctAnswer = new CorrectAnswer(new Word("spill")); | ||
|
|
||
| List<Tile> tiles = correctAnswer.compare(new Word("hello")); | ||
|
|
||
| assertThat(tiles).containsExactly(Tile.GRAY, Tile.GRAY, Tile.YELLOW, Tile.GREEN, Tile.GRAY); | ||
| } | ||
|
|
||
| @DisplayName("그린 1개, 노란색 1개, 회색 3개인 답안을 비교한다.") | ||
| @Test | ||
| void test02() { | ||
| CorrectAnswer correctAnswer = new CorrectAnswer(new Word("spill")); | ||
|
|
||
| List<Tile> tiles = correctAnswer.compare(new Word("label")); | ||
|
|
||
| assertThat(tiles).containsExactly(Tile.YELLOW, Tile.GRAY, Tile.GRAY, Tile.GRAY, Tile.GREEN); | ||
| } | ||
|
|
||
| @DisplayName("입력된 답안을 존재하는 Word 인지 비교한다.") | ||
| @Test | ||
| void test03() { | ||
| CorrectAnswer correctAnswer = new CorrectAnswer(new Word("spill")); | ||
|
|
||
| List<Tile> tiles = correctAnswer.compare(new Word("spell")); | ||
|
|
||
| assertThat(tiles).containsExactly(Tile.GREEN, Tile.GREEN, Tile.GRAY, Tile.GREEN, Tile.GREEN); | ||
| } | ||
|
|
||
| @DisplayName("입력된 답안을 존재하는 Word 인지 비교한다.") | ||
| @Test | ||
| void test04() { | ||
| CorrectAnswer correctAnswer = new CorrectAnswer(new Word("spill")); | ||
|
|
||
| List<Tile> tiles = correctAnswer.compare(new Word("spill")); | ||
|
|
||
| assertThat(tiles).containsExactly(Tile.GREEN, Tile.GREEN, Tile.GREEN, Tile.GREEN, Tile.GREEN); | ||
| }*/ |
There was a problem hiding this comment.
Controller, Service 네이밍을 통해서 MVC 패턴을 적용했다는 의도가 한번에 느껴지네요.👍
There was a problem hiding this comment.
FileConfig 클래스에서 file 관련 설정을 관리하셨네요. 이렇게 하면 추후 파일관련 내용이 추가되더라도 응집도 높은 코드를 작성할 수 있겠네요.😃
|
|
||
| public class InputView { | ||
|
|
||
| public static final int GAME_TOTAL_ROUND = 6; |
There was a problem hiding this comment.
GAME_TOTAL_ROUND 상수는 InputView 보다는 GameService 클래스에서 관리하는게 더 좋아보이는데 어떻게 생각하시나요?
| try { | ||
| return Files.readAllLines(Paths.get(filePath)); | ||
| } catch (IOException e) { | ||
| throw new RuntimeException("파일을 읽을 수 없습니다.", e); | ||
| } |
There was a problem hiding this comment.
파일이 없는 경우에 발생하는 NoSuchFileException과 같이 구체적인 예외를 작성해보는건 어떨까요?
|
|
||
| private static final String INPUT_WORD_MESSAGE = "정답을 입력해주세요."; | ||
|
|
||
| private static final Scanner scanner = new Scanner(System.in); |
There was a problem hiding this comment.
Scanner가 게임 종료후에도 close 선언을 하지 않은것 같습니다.
scanner 리소스를 닫아주는것은 어떨까요?
There was a problem hiding this comment.
근데 고민이 되는게, static 이라서 닫으려면 쓸때마다 쓰고 닫고 해야할 것 같은데 고민이군요.
다른곳들은 안닫더라구요.
| Long count = letterMap.get(answer.getWord().get(i)); | ||
|
|
||
| Tile tile = getTile(count, this.answer.getWord().get(i), answer.getWord().get(i)); | ||
| result.add(tile); | ||
|
|
||
| letterMap.put(answer.getWord().get(i), letterMap.getOrDefault(answer.getWord().get(i), 0L) - 1); | ||
| } | ||
| endGame(result); | ||
|
|
There was a problem hiding this comment.
음 너무 길어져서 10줄이 넘어서 ㅋㅋㅋ 재선언 안하긴 했습니다.
다른방법으로 구현을 리팩터링 해야할 것 같네요.
There was a problem hiding this comment.
enum을 활용해서 각각의 종류에 맞는 이모지를 할당하셨세요.
깔끔하고 명확안 코드인것 같습니다.😃
| } | ||
|
|
||
| private void endGame(List<Tile> result) { | ||
| int count = Collections.frequency(result, Tile.GREEN); |
There was a problem hiding this comment.
이런 Collections 메서드가 있는줄 처음 알았네요. 덕분에 배워갑니다!❤
페어: 하현님