Skip to content

[로또 미션] 김명지 미션 제출합니다. #34

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
wants to merge 27 commits into
base: starlight258
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5abe2a2
refactor: 리팩토링
Starlight258 Jun 18, 2024
685ce55
fix: 우승자 예외 처리 버그 수정
Starlight258 Jun 18, 2024
0f84cc2
refactor: 함수형 인터페이스 활용
Starlight258 Jun 18, 2024
7def5fb
refactor: 메서드 private으로 변경
Starlight258 Jun 18, 2024
6fbbe0b
test: WinningRank 테스트 작성
Starlight258 Jun 18, 2024
204eec4
refactor: 반환값 수정
Starlight258 Jun 18, 2024
dd3feb1
feat: 로또 수동 구매 기능 구현
Starlight258 Jun 22, 2024
3f1a41a
feat: LottoCount 값 객체 생성
Starlight258 Jun 22, 2024
e3c8191
refactor: inputView에서 outputView 의존성 제거
Starlight258 Jun 22, 2024
f01e1ac
fix: 가격 배수 더하기 버그 수정
Starlight258 Jun 22, 2024
2b05742
refactor: 리팩토링
Starlight258 Jun 22, 2024
48e7deb
refactor: 메서드 10줄 이하로 리팩토링
Starlight258 Jun 22, 2024
0232fab
test: LottoCount 테스트 추가
Starlight258 Jun 22, 2024
49c785c
test: 테스트 작성
Starlight258 Jun 22, 2024
c61bd49
refactor: 사용하지 않는 메서드 삭제
Starlight258 Jun 22, 2024
17e4d69
refactor: Lotto 내부 컬렉션 Set로 변경
Starlight258 Jun 22, 2024
dda74be
refactor: 매개변수에 final 사용하여 불변성 표현
Starlight258 Jun 22, 2024
6a3581d
rename: LottoResult를 LottoStatistics로 변경
Starlight258 Jun 23, 2024
63711c3
refactor: 필요없는 메서드 제거 및 메서드명 변경
Starlight258 Jun 23, 2024
c4f33e2
refactor: 입력을 받는 컬렉션에 방어적 복사 수행
Starlight258 Jun 23, 2024
20eb06c
docs: README 업데이트
Starlight258 Jun 23, 2024
7b9c6fa
refactor: 메서드 파라미터 타입 변경
Starlight258 Jul 1, 2024
e715e31
refactor: LottoStatistics에서 WinningRank 자체를 key로 사용
Starlight258 Jul 1, 2024
4e486aa
rename: LottoStatistics.java -> LottoResult.java
Starlight258 Jul 1, 2024
2ff823c
feat: lotto 출력 오름차순으로 수정
Starlight258 Jul 1, 2024
4188aec
rename: 패키지명 변경
Starlight258 Jul 1, 2024
2134c60
docs: README.md 업데이트
Starlight258 Jul 1, 2024
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
231 changes: 145 additions & 86 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- `Application` : 로또 실행을 담당하는 진입점 클래스

## model
## domain

- `Price` : 구매 가격 VO

Expand All @@ -13,21 +13,21 @@
- `LottoNumber` : 로또 번호 VO
- `Lotto` : 로또 객체
- `Lottos` : 여러 개의 Lotto 객체를 관리하는 일급 컬렉션
- `LottoResult` : 로또 결과 VO
- `LottoResult` : 로또 당첨 결과 객체
- `LottoCount` : 로또 구매 개수 VO

#### constant

- `LottoBoundary` : 로또 경계값 상수
- `LottoMatch` : 로또 당첨 결과 상수
- `WinningRank` : 당첨 순위 Enum

## view
## io

- `InputView` : 입력을 담당하는 클래스
- `OutputView` : 출력을 담당하는 클래스

## controller
## game

- `LottoController` : 로또 전체 흐름을 제어하는 클래스
- `LottoGame` : 로또 게임을 담당하는 클래스

<br/>

Expand All @@ -44,23 +44,23 @@

```java
구입금액을 입력해 주세요.
14000

14개를 구매했습니다.
[8,21,23,41,42,43]
[3,5,11,16,32,38]
[7,11,16,35,36,44]
[1,8,11,31,41,42]
[13,14,16,38,42,45]
[7,11,30,40,42,43]
[2,13,22,32,38,45]
[23,25,33,36,39,41]
[1,3,5,14,22,45]
[5,9,38,41,43,44]
[2,8,9,18,19,21]
[13,14,18,21,23,35]
[17,21,29,37,42,45]
[3,8,27,30,35,44]
14000

14개를 구매했습니다.
[8,21,23,41,42,43]
[3,5,11,16,32,38]
[7,11,16,35,36,44]
[1,8,11,31,41,42]
[13,14,16,38,42,45]
[7,11,30,40,42,43]
[2,13,22,32,38,45]
[23,25,33,36,39,41]
[1,3,5,14,22,45]
[5,9,38,41,43,44]
[2,8,9,18,19,21]
[13,14,18,21,23,35]
[17,21,29,37,42,45]
[3,8,27,30,35,44]
```

### 새로운 프로그래밍 요구사항
Expand Down Expand Up @@ -90,34 +90,34 @@

```java
구입금액을 입력해 주세요.
14000

14개를 구매했습니다.
[8,21,23,41,42,43]
[3,5,11,16,32,38]
[7,11,16,35,36,44]
[1,8,11,31,41,42]
[13,14,16,38,42,45]
[7,11,30,40,42,43]
[2,13,22,32,38,45]
[23,25,33,36,39,41]
[1,3,5,14,22,45]
[5,9,38,41,43,44]
[2,8,9,18,19,21]
[13,14,18,21,23,35]
[17,21,29,37,42,45]
[3,8,27,30,35,44]

지난 주 당첨 번호를 입력해 주세요.
1,2,3,4,5,6

당첨 통계
---------
3개 일치(5000원)-1개
4개 일치(50000원)-0개
5개 일치(1500000원)-0개
6개 일치(2000000000원)-0개
총 수익률은0.35입니다.(기준이 1이기 때문에 결과적으로 손해라는 의미임)
14000

14개를 구매했습니다.
[8,21,23,41,42,43]
[3,5,11,16,32,38]
[7,11,16,35,36,44]
[1,8,11,31,41,42]
[13,14,16,38,42,45]
[7,11,30,40,42,43]
[2,13,22,32,38,45]
[23,25,33,36,39,41]
[1,3,5,14,22,45]
[5,9,38,41,43,44]
[2,8,9,18,19,21]
[13,14,18,21,23,35]
[17,21,29,37,42,45]
[3,8,27,30,35,44]

지난 주 당첨 번호를 입력해 주세요.
1,2,3,4,5,6

당첨 통계
---------
3개 일치(5000원)-1개
4개 일치(50000원)-0개
5개 일치(1500000원)-0개
6개 일치(2000000000원)-0개
총 수익률은0.35입니다.(기준이 1이기 때문에 결과적으로 손해라는 의미임)

```

Expand All @@ -130,47 +130,106 @@

- 2등을 위한 보너스볼을 추첨한다.
- 당첨 통계에 2등을 추가한다.
- 2등 당첨 조건은 당첨 번호 5개 일치 + 보너스 볼 일치다.
- 2등 당첨 조건은 당첨 번호 5개 일치 + 보너스 볼 일치다.

실행 결과

- 실행 결과

위 요구사항에 따라 14000원 어치 로또를 구매하였을 경우 프로그램을 실행한 결과는 다음과 같다.

```java
구입금액을 입력해 주세요.
14000

14개를 구매했습니다.
[8,21,23,41,42,43]
[3,5,11,16,32,38]
[7,11,16,35,36,44]
[1,8,11,31,41,42]
[13,14,16,38,42,45]
[7,11,30,40,42,43]
[2,13,22,32,38,45]
[23,25,33,36,39,41]
[1,3,5,14,22,45]
[5,9,38,41,43,44]
[2,8,9,18,19,21]
[13,14,18,21,23,35]
[17,21,29,37,42,45]
[3,8,27,30,35,44]

지난 주 당첨 번호를 입력해 주세요.
1,2,3,4,5,6

보너스 볼을 입력해 주세요.
7

당첨 통계
---------
3개 일치(5000원)-1개
4개 일치(50000원)-0개
5개 일치(1500000원)-0개
5개 일치,보너스 볼 일치(30000000원)-0개
6개 일치(2000000000원)-0개
총 수익률은0.35입니다.(기준이 1이기 때문에 결과적으로 손해라는 의미임)
14000

14개를 구매했습니다.
[8,21,23,41,42,43]
[3,5,11,16,32,38]
[7,11,16,35,36,44]
[1,8,11,31,41,42]
[13,14,16,38,42,45]
[7,11,30,40,42,43]
[2,13,22,32,38,45]
[23,25,33,36,39,41]
[1,3,5,14,22,45]
[5,9,38,41,43,44]
[2,8,9,18,19,21]
[13,14,18,21,23,35]
[17,21,29,37,42,45]
[3,8,27,30,35,44]

지난 주 당첨 번호를 입력해 주세요.
1,2,3,4,5,6

보너스 볼을 입력해 주세요.
7

당첨 통계
---------
3개 일치(5000원)-1개
4개 일치(50000원)-0개
5개 일치(1500000원)-0개
5개 일치,보너스 볼 일치(30000000원)-0개
6개 일치(2000000000원)-0개
총 수익률은0.35입니다.(기준이 1이기 때문에 결과적으로 손해라는 의미임)
```

### 새로운 프로그래밍 요구사항

Java Enum을 적용한다.

### 4단계 - 로또 수동 구매

- 현재 로또 생성기는 자동 생성 기능만 제공한다. 사용자가 수동으로 추첨 번호를 입력할 수 있도록 해야 한다.
- 입력한 금액, 자동 생성 숫자, 수동 생성 번호를 입력하도록 해야 한다.

실행 결과

- 위 요구사항에 따라 14000원 어치 중 수동 3개, 자동 11개를 구매한 경우 프로그램을 실행한 결과는 다음과 같다.

```java
구입금액을 입력해 주세요.
14000

수동으로 구매할 로또 수를 입력해 주세요.
3

수동으로 구매할 번호를 입력해 주세요.
8,21,23,41,42,43
3,5,11,16,32,38
7,11,16,35,36,44

수동으로 3장,자동으로 11개를 구매했습니다.
[8,21,23,41,42,43]
[3,5,11,16,32,38]
[7,11,16,35,36,44]
[1,8,11,31,41,42]
[13,14,16,38,42,45]
[7,11,30,40,42,43]
[2,13,22,32,38,45]
[23,25,33,36,39,41]
[1,3,5,14,22,45]
[5,9,38,41,43,44]
[2,8,9,18,19,21]
[13,14,18,21,23,35]
[17,21,29,37,42,45]
[3,8,27,30,35,44]

지난 주 당첨 번호를 입력해 주세요.
1,2,3,4,5,6

보너스 볼을 입력해 주세요.
7

당첨 통계
---------
3개 일치(5000원)-1개
4개 일치(50000원)-0개
5개 일치(1500000원)-0개
5개 일치,보너스 볼 일치(30000000원)-0개
6개 일치(2000000000원)-0개
총 수익률은0.35입니다.(기준이 1이기 때문에 결과적으로 손해라는 의미임)
```

### 5단계 - 리팩터링

- 기존 프로그래밍 요구사항을 다시 한번 확인하고, 학습 테스트를 통해 학습한 내용을 반영한다.
12 changes: 6 additions & 6 deletions src/main/java/org/duckstudy/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.duckstudy.controller.LottoController;
import org.duckstudy.view.InputView;
import org.duckstudy.view.OutputView;
import org.duckstudy.game.LottoGame;
import org.duckstudy.io.InputView;
import org.duckstudy.io.OutputView;

public class Application {
public static void main(String[] args) {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
OutputView outputView = new OutputView();
InputView inputView = new InputView(bufferedReader, outputView);
InputView inputView = new InputView(bufferedReader);

LottoController lottoController = new LottoController(outputView, inputView);
lottoController.run();
LottoGame lottoGame = new LottoGame(outputView, inputView);
lottoGame.run();
}
}
78 changes: 0 additions & 78 deletions src/main/java/org/duckstudy/controller/LottoController.java

This file was deleted.

Loading