[숫자 야구 게임] 한보은 미션 제출합니다.#852
Conversation
coolOlive
left a comment
There was a problem hiding this comment.
남겨주신 리뷰 많은 도움 되었습니다 😄
전체적인 흐름을 따라 코드가 잘 읽히게 구현하셨네요!
코드 보고 코맨트 달아놨습니다. 작지만 도움이 되면 좋겠어요.
| @@ -0,0 +1,72 @@ | |||
| import { MissionUtils } from '@woowacourse/mission-utils'; | |||
There was a problem hiding this comment.
import { Console, Random } from '@woowacourse/mission-utils';이렇게 선언하면 이후에 MissionUtils.Random()을 Random()로 줄여서 쓸 수 있어요!
|
|
||
| constructor() { | ||
| this.numbers = []; | ||
| } |
There was a problem hiding this comment.
airbnb 스타일 가이드에 따르면 구문의 앞과 블록의 뒤에는 빈 행을 두는 것이 좋다고 해요.
There was a problem hiding this comment.
미처 확인하지 못한 컨벤션이네요..알려주셔서 감사합니다!
| else if (ball === 0) return `${strike}스트라이크`; | ||
| else if (strike === 0) return `${ball}볼`; | ||
| else return `${ball}볼 ${strike}스트라이크`; |
There was a problem hiding this comment.
앞의 if문에 return이 있으니
뒤에서부터는 else if 대신 if를 써도 될 것 같습니다!
| while (true) { | ||
| this.pickRandomNumbers(); | ||
| while (true) { | ||
| const input = await user.getUserNumber(); | ||
| const result = this.getMessage(input); | ||
| MissionUtils.Console.print(result.result); | ||
| if (result.success) { | ||
| MissionUtils.Console.print( | ||
| '3개의 숫자를 모두 맞히셨습니다! 게임 종료' | ||
| ); | ||
| break; | ||
| } | ||
| } |
There was a problem hiding this comment.
playGame()에 모든 기능을 넣기 보다는 내부에 있는 while문과 if문을 새로운 함수로 만들어 사용하는게 좋을 것 같아 제안합니다!! :D
기능별로 나누어 함수를 만드는 게 나중에 리팩토링하고 테스트를 진행할 때 좋을 것 같아요.
There was a problem hiding this comment.
2주차 때는 좀더 코드를 기능별로 분리해보겠습니다. 조언 감사합니다!
|
리뷰 남겨주셔서 감사합니다! computer와 user로 클래스를 나누어 각 클래스 별로 매서드가 정의되어 있어 확실히 잘 읽히네요! 잘 모르는 제가 봐도 코드가 확실히 깔끔한 것 같아요. |
No description provided.