Open
Conversation
문제를 바탕으로 요구사항을 분석하고, 분석한 요구사항을 바탕으로 TODO를 작성하였습니다.
요구사항에 맞추어 Validator 객체의 checkIsValidAmount 테스트 코드를 작성하였습니다. - 구매 금액은 500원 단위의 양의정수여야한다.
OutputView의 printErrorMessage 메서드에서 접두사를 붙이고 있습니다. 이에 따라서 중복으로 메시지에 접두사를 붙이지 않도록 수정하였습니다. 변경된 코드에 맞추어 테스트 코드도 수정하였습니다.
입력을 받는 모든 곳에서 에러 메시지 출력 및 다시 입력을 받는 기능이 수반됩니다. 이에 따라서 해당 기능을 추상화한 handleInputError를 구현하였습니다. handleInputError는 아래와 같이 구성되어있습니다. - 입력 로직 : 입력을 받는 비동기 함수. - validator : 입력 로직이 반환한 값을 넣어서 실행하는 함수 - parser : 입력받은 값을 변경해서 반환하는 함수 각 단계에서 에러가 잡히게 되면, 다시 해당 입력 로직이 실행되도록 하였습니다.
- 로또 1개의 가격을 상수로서 관리하도록 구현
- 로또의 가격은 500원 이어야 한다. 이는 정적 멤버여야한다. - 로또는 생성자를 통해 발행 가능하다. - 생성자에는 올바른 번호 6자리를 입력받아야 한다. - 로또 번호의 범위는 1 ~ 30 이다. - 생성한 로또의 번호는 getLottoNumbers 를 통하여 가져올 수 있어야 한다.
외부 의존성이다보니 해당 로직을 따로 빼서 사용하는 곳에서 테스트가 쉽도록 주입하게 하려했습니다.
- 요구사항에 맞추어 5개만 입력받을 수 있도록 수정하였습니다.
- 특정 객체에 종속되지 않는 것이 좋아보여 static으로 구현하였습니다.
- 로또를 구매하고 구매한 로또와 관련된 일련의 작업을 LottoDevice에서 하도록 하였습니다. - 로또를 발행하기 위해 랜덤한 수를 뽑아야 합니다. 다만 이는 "로또 발행"에 종속된 동작이므로 유틸 함수가 아닌 해당 클래스에 넣었습니다.
올바른 validator로 수정하였습니다.
calcRank를 통하여 등수를 반환할 때 0으로 반환된 값을 카운트 하도록 수정하였습니다
- constants.js에 있는 LOTTO_COST값 제거 - utils.js에 있는 getRandomLottoNumbers 제거 - handleInputError의 parser 문 제거
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
javascript-planetlotto-precourse
요구사항 분석
1. 구입 금액 입력
입력 요구사항
2. 구매 내역 출력
3. 당첨 번호 입력
입력 요구사항
e.g.
4. 보너스 번호 입력
입력 요구사항
5. 당첨 통계 출력
구현 사항
1. 구입 금액 입력
2. 구매 내역 출력
구입금액 / 5003. 당첨 번호 입력
4. 보너스 번호 입력
5. 당첨 통계 출력
리팩토링 구현 사항
최소 조건
추가 조건