Skip to content
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

[로또] 김승진 미션 제출합니다. #3

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6e33a4e
docs(README): 리드미에 기능 및 클래스 목록 작성
ohksj77 Aug 6, 2023
95d2b33
feat: 난수 생성을 통한 Lotto 객체 생성
ohksj77 Aug 6, 2023
2e8060e
feat(LottoRepository): 로또 repository 저장 기능
ohksj77 Aug 6, 2023
7af6ea4
feat(InputManager): 입력 담당 클래스 및 입력 받는 함수 추가
ohksj77 Aug 6, 2023
09c870a
feat: 출력 담당 클래스 및 입력 검증 추가
ohksj77 Aug 6, 2023
94d063d
feat: 로또 발행량 계산
ohksj77 Aug 6, 2023
abbcead
feat(FrontController): 프론트 컨트롤러 추가
ohksj77 Aug 6, 2023
b7400f8
feat: 로또 티켓 발행
ohksj77 Aug 6, 2023
adb9f48
feat: 발행한 로또 티켓 출력 기능
ohksj77 Aug 6, 2023
c9ff2dc
docs(README): 열거형 및 함수 설명 추가
ohksj77 Aug 6, 2023
b0e4bb9
feat: 당첨번호 입력 기능 추가
ohksj77 Aug 6, 2023
c494bfb
feat(WinningNumber): 당첨 번호 입력 기능
ohksj77 Aug 6, 2023
80aac32
feat: 당첨 번호 입력값 검증
ohksj77 Aug 6, 2023
c685be4
docs(README): 입력값 검증 관련 리드미 추가
ohksj77 Aug 6, 2023
a725d88
test: 서비스와 입력값 검증 테스트 추가
ohksj77 Aug 6, 2023
393fc6b
refactor: 클래스 삭제 및 enum 이름 수정
ohksj77 Aug 6, 2023
344755a
feat: 결과 도출 기능 및 출력 기능
ohksj77 Aug 6, 2023
764d6a9
feat: 발행량 저장 로직 추가
ohksj77 Aug 6, 2023
3bb834e
feat: 수익률 조회 기능 추가
ohksj77 Aug 6, 2023
20d47c6
refactor: 테스트 오류 수정
ohksj77 Aug 6, 2023
b748063
refactor: 불필요 클래스 삭제
ohksj77 Aug 6, 2023
e322f89
refactor: 상수 미적용 부분 적용
ohksj77 Aug 6, 2023
ad39158
feat(OutputFormatter): 출력 문자열 변환 클래스 추가
ohksj77 Aug 6, 2023
bca2c44
docs: 완료 기능 목록 수정
ohksj77 Aug 6, 2023
dd7ecb6
feat: 에러 핸들링
ohksj77 Aug 7, 2023
9760d80
feat: 에러 핸들링
ohksj77 Aug 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: 발행량 저장 로직 추가
기능 추가
- 발행량 저장, 조회 기능
ohksj77 committed Aug 6, 2023

Unverified

This user has not yet uploaded their public signing key.
commit 764d6a9827a1db04985501448ed7dc74ed109558
4 changes: 3 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@

## LottoService - 로또 서비스
- saveLotto() 랜덤한 숫자 생성을 통한 Lotto 생성 및 저장
- getPublishNum() 로또 발행량 계산
- savePublishNum() 로또 발행량 계산 및 저장
- publishLotto() 로또 티켓 발행
- saveWinningNumber() 당첨 번호 저장
- checkWinningNumber() 당점 정보 비교 및 결과 계산
@@ -41,6 +41,8 @@
- saveWinningNumber() WinningNumber 객체 저장
- findAllLotto() 로또 전체 조회
- findWinningNumber() 당첨 번호 조회
- savePublishNumber() 발행량 저장
- findPublishNumber() 발행량 조회

## InputManager - 입력 받기
- buyAmountInput() 구매 금액 입력
4 changes: 2 additions & 2 deletions src/main/java/lotto/FrontController.java
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@ public FrontController(final LottoController lottoController) {
}

public void playLotto() {
final Integer publishNum = lottoController.getPublishNum();
lottoController.publishLotto(publishNum);
lottoController.getPublishNum();
lottoController.publishLotto();
lottoController.getWinningNumber();
lottoController.checkWinningNumber();
}
9 changes: 4 additions & 5 deletions src/main/java/lotto/LottoController.java
Original file line number Diff line number Diff line change
@@ -13,18 +13,17 @@ public LottoController(final LottoService lottoService, final OutputManager outp
this.inputManager = inputManager;
}

public Integer getPublishNum() {
public void getPublishNum() {
outputManager.printStartMessage();

final Integer buyAmount = inputManager.buyAmountInput();
final Integer publishNum = lottoService.getPublishNum(buyAmount);
final Integer publishNum = lottoService.savePublishNum(buyAmount);

outputManager.printPublishNum(publishNum);
return publishNum;
}

public void publishLotto(final Integer publishNum) {
final List<Lotto> lottoList = lottoService.publishLotto(publishNum);
public void publishLotto() {
final List<Lotto> lottoList = lottoService.publishLotto();
outputManager.printLottoList(lottoList);
}

9 changes: 9 additions & 0 deletions src/main/java/lotto/LottoRepository.java
Original file line number Diff line number Diff line change
@@ -5,6 +5,15 @@
public class LottoRepository {
private List<Lotto> lotto;
private WinningNumber winningNumber;
private Integer publishNumber;

public void savePublishNumber(final Integer publishNumber) {
this.publishNumber = publishNumber;
}

public Integer findPublishNumber() {
return this.publishNumber;
}

public void saveAllLotto(final List<Lotto> lotto) {
this.lotto = lotto;
11 changes: 7 additions & 4 deletions src/main/java/lotto/LottoService.java
Original file line number Diff line number Diff line change
@@ -22,16 +22,19 @@ private List<Integer> createRandomNumbers() {
LottoNumberRange.NUMBER_NUM.toValue());
}

public Integer getPublishNum(final Integer buyAmount) {
return divideByMoneyUnit(buyAmount);
public Integer savePublishNum(final Integer buyAmount) {
final Integer publishNumber = divideByMoneyUnit(buyAmount);
lottoRepository.savePublishNumber(publishNumber);
return publishNumber;
}

private Integer divideByMoneyUnit(final Integer dividend) {
return dividend / MONEY_UNIT;
}

public List<Lotto> publishLotto(final Integer publishNum) {
final List<Lotto> lottoList = createLottoList(publishNum);
public List<Lotto> publishLotto() {
final Integer publishNumber = lottoRepository.findPublishNumber();
final List<Lotto> lottoList = createLottoList(publishNumber);
lottoRepository.saveAllLotto(lottoList);
return lottoList;
}
4 changes: 2 additions & 2 deletions src/test/java/lotto/LottoServiceTest.java
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ void getPublishNum() {
//given

//when
final Integer publishNum = lottoService.getPublishNum(1000);
final Integer publishNum = lottoService.savePublishNum(1000);

//then
assertThat(publishNum).isEqualTo(1);
@@ -29,7 +29,7 @@ void publishLotto() {
//given

//when
final List<Lotto> lottoList = lottoService.publishLotto(1);
final List<Lotto> lottoList = lottoService.publishLotto();

//then
assertThat(lottoList).hasSize(1);