-
Notifications
You must be signed in to change notification settings - Fork 192
[로또] 박규영 미션 제출합니다. #178
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
Open
cloudsoswift
wants to merge
13
commits into
woowacourse-precourse:main
Choose a base branch
from
cloudsoswift:cloudsoswift
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[로또] 박규영 미션 제출합니다. #178
cloudsoswift
wants to merge
13
commits into
woowacourse-precourse:main
from
cloudsoswift:cloudsoswift
+188
−2
Conversation
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
프로젝트 개요, 프로세스 흐름, 구현할 기능 목록을 ./README.md에 작성
로또 구입 금액을 입력받는 함수 setupLottoBudget 추가 - 입력 받은 값이 정수가 아니거나, 1000 미만 또는 1000 단위가 아닐 경우 에러 - 정상적인 경우 Number 형으로 변환한 금액 반환
1~45 사이 랜덤 숫자 6개로 Lotto 인스턴스를 생성하는 함수 - Random.pickUniqueNumberInRange를 사용해 랜덤 숫자 생성하며, Array.sort()를 통해 오름차순으로 정렬한 뒤 Lotto 생성자에 전달
구입 금액만큼 복권을 발행하는 purchaseLotto와 Lotto의 번호를 출력 폼에 맞춘 문자열로 반환하는 Lotto.toString() 메서드 추가 - purchaseLotto는 (입력받은 금액 / 1000) 만큼 createLotto를 반복 호출해 Lotto 인스턴스를 생성한 뒤 배열에 담아 반환 - Lotto.toString은 Lotto의 번호(#numbers)를 규격에 맞춘 문자열 형태로 반환
…ationWinningNum 쉼표로 구분되는 6개의 당첨 번호를 입력 받아 이를 검증 후 배열로 반환하는 setupWinningNum 함수 추가 - 당첨 번호 검증에 필요한 validateWinningNum, checkDuplicationWinningNum 함수 추가 - validateWinningNum 함수는 각 당첨 번호가 1 ~ 45 사이의 정수인지 검사 - checkDuplicationWinningNum 함수는 당첨 번호 중 중복이 있는지 검사
보너스 번호를 입력받는 함수 setupBonusNum 추가 - 입력 받은 값이 정수가 아니거나, 1 ~ 45 구간 사이의 값이 아닐 경우 에러 - 인자로 받은 당첨 번호들(winningNumbers)과 보너스 번호 간 중복이 발생할 경우 에러
…WinningStatus 구매한 로또들의 당첨 내역을 기록하는 함수 checkLotteriesResult 추가 - 이를 위해 당첨 등수를 계산하는 함수 calculateRank, 맞은 번호 개수 및 보너스 번호 적중 여부를 반환하는 함수 Lotto.checkWinningStatus를 추가 - calculateRank는 당첨 번호 개수 및 보너스 번호 적중 여부를 인자로 받아, 당첨 등수를 반환 - Lotto.checkWinningStatus는 당첨 번호와 보너스 번호를 인자로 받아 일치하는 당첨 번호 개수 및 보너스 번호 일치 여부를 반환
기록된 당첨 내역을 바탕으로 수익률을 계산하고 이들을 출력하는 함수 calculateProfit() 추가 - 복권 구입 금액과 등수 별 당첨 횟수가 기록된 배열을 인자로 받음 - 각 등수에 당첨된 복권 개수를 출력하고, 총 이익에 누계 - 이후 총 이익을 복권 구입 금액으로 나눈 위 소수점 둘째자리에서 반올림하여 수익률로 출력
서비스 프로세스에 맞춰 각 함수를 호출하는 메서드 App.run() 작성 - 또한, Lotto 파일의 확장자를 명시해 import 오류 수정
Lotto.checkWinningStatus 메서드의 동작 방식을 일부 수정 - bonusNumber와 일치하는지 먼저 확인 후, winningNumbers[winningNumIdx] 와 일치하는지 확인하도록 수정 - 또한, winningNumbers[winningNumIdx]와 일치하는지 확인할 때 일치한다면 winningNumIdx도 증가시키도록 수정
…, change validation App 내부의 함수들의 세부 사항 일부 수정 - Console.readLineAsync()를 호출하는 함수들에 대해, 인자로 넘기는 문자열에 줄바꿈 문자(\n)추가 - 입력 값이 정수인지 판별하는 식 수정 - Random.pickUniqueNumbersInRange 호출하는 부분 함수 이름 틀린 것 수정 - await Console.readLineAsync()문 뒤에 split()을 바로 호출하던 것 수정 - setupBonusNum에 당첨 번호들(winningNumbers) 넘기지 않던것 수정
checkWinningStatus의 당첨 번호 개수 카운팅 로직을 수정하고, validate의 검증 과정을 추가 - Array.filter, Array.includes를 사용해 당첨 번호와 보너스 번호가 있는지 파악하도록 수정 - 로또 번호가 정수인지, 중복된 수가 있는지도 검사하도록 수정
줄바꿈 출력 수정, 정수인지 판별하는 로직 수정, calculateProfit에서 누적 이익 계산시 RankCount의 잘못된 위치를 참조하던 것과 수익률 계산식 수정
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.
No description provided.