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

๐Ÿ”€ [hanse & sally] ๋กœ๋˜ 2๋‹จ๊ณ„ - ๋ณด๋„ˆ์Šค ๋ฒˆํ˜ธ ์ถ”๊ฐ€ #45

Open
wants to merge 15 commits into
base: sally-ksh
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
f0573f7
feat : Input ํด๋ž˜์Šค, Main ํด๋ž˜์Šค
rkolx Feb 24, 2022
d069d61
refactor : ๋‹น์ฒจ๋ฒˆํ˜ธ ๋ชจ์Œ ํด๋ž˜์Šค ๋ฐ ํด๋ž˜์Šค ๋ช… ์ˆ˜์ •
rkolx Feb 24, 2022
8d41897
feat : ๋ณด๋„ˆ์Šค ๋ฒˆํ˜ธ ์ถ”๊ฐ€
rkolx Feb 24, 2022
d69a5ee
refactor: ๋กœ๋˜ ๊ฒฐ๊ณผ ๋กœ์ง ๋ฆฌํŒฉํ† ๋ง
sally-ksh Feb 24, 2022
141f826
refactor: ๋ณด๋„ˆ์Šค๋ณผ ์ถ”๊ฐ€ ์‚ฌํ•ญ ์ถ”์ƒํ™”
sally-ksh Feb 24, 2022
696896e
refactor: LottoPlay ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง ๋ถ„๋ฆฌ
sally-ksh Feb 24, 2022
ec5169b
feat: ํŒจํ‚ค์ง€ ๋ถ„๋ฆฌ
sally-ksh Feb 24, 2022
d7ca355
refactor: ๋ณด๋„ˆ์Šค๋ณผ ์ƒ์†์œผ๋กœ ๋ณ€๊ฒฝ
sally-ksh Feb 25, 2022
72bc927
fix
sally-ksh Feb 25, 2022
b9df53d
refactor : ๋กœ๋˜ ๋‹ด๋Š” ๋ฉ”์„œ๋“œ ์—ญํ• ์— ๋”ฐ๋ผ ๋ถ„๋ฆฌ
rkolx Feb 25, 2022
7ac4a2b
docs : 2๋‹จ๊ณ„ ์š”๊ตฌ์‚ฌํ•ญ์— ๋งž๊ฒŒ RADME.md ์ˆ˜์ •
rkolx Feb 25, 2022
ee3deaa
refacfor : gettotalLottos ๋ฉ”์„œ๋“œ ๋ถ„๋ฆฌ
rkolx Feb 25, 2022
79bfcec
refactor : ๋™์ž‘ ํด๋ž˜์Šค๋ช… ์ˆ˜์ •
rkolx Feb 25, 2022
73388b2
refactor: ๋ฆฌ๋ทฐ ๋ฐ˜์˜
sally-ksh Feb 26, 2022
8271d2d
Merge pull request #1 from sally-ksh/sally-step2
sally-ksh Feb 26, 2022
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
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
# java-lotto
๋งˆ์Šคํ„ฐ์ฆˆ ๋ฉค๋ฒ„์Šค 2022 ๋กœ๋˜ ๊ฒŒ์ž„ ํ”„๋กœ์ ํŠธ


- โœ๏ธ from reviewer
- countNumberOfWinnings() for๋ฌธ ๋Œ€์‹  stream์œผ๋กœ ๊ฐœ์„ 
- boolean ํ•จ์ˆ˜ํ˜• ๋ฐ˜ํ™˜ ์ด์šฉํ•œ ๊ฒฐ๊ณผ ๋ฆฌํ„ด์‹œ ๋ถˆํ•„์š”ํ•œ ์กฐ๊ฑด๋ฌธ์„ ์“ฐ์ง€ ์•Š๊ธฐ
- ํŒจํ‚ค์ง€๋ช…์— ๋ณต์ˆ˜ํ˜•์„ ์ž˜ ์“ฐ์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
- Lotto ๊ฐ์ฒด๊ฐ€ ์ง์ ‘ Ranking ๊ฒฐ๊ณผ๊ฐ’์„ ์ฃผ๋Š” ๋ฐฉ์‹์œผ๋กœ ๊ฐœ์„ ํ•ด์•ผ ํ•˜์ง€ ์•Š์„๊นŒ์š”?
- ๋‹น์ฒจ๋ฒˆํ˜ธ ๋ฆฌ์ŠคํŠธ๋ฅผ ๋ณด๊ด€ํ•  ๋งŒํ•œ ๊ฐ์ฒด๋ฅผ ์„ค๊ณ„ํ•ด์„œ ๊ทธ ๊ฐ์ฒด์˜ ๋ฆฌ์ŠคํŠธ๋กœ ์ „๋‹ฌํ•ด์ฃผ๋ฉด ๋” ์ข‹์„ํ…๋ฐ์š”?
- java.util.ArrayList ์—๋งŒ ์กด์žฌํ•˜๋Š” ๋ฉ”์„œ๋“œ๋‚˜ ๋กœ์ง์— ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ๊ฐ•๊ฒฐํ•ฉ๋˜์–ด์•ผ ํ•  ํŠน๋ณ„ํ•œ ์ด์œ ๊ฐ€ ์žˆ์„๊นŒ์š”?
๊ทธ๋ ‡์ง€ ์•Š๋‹ค๋ฉด ํ•ญ์ƒ List<T> ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.
- [link](https://stackoverflow.com/questions/9852831/polymorphism-why-use-list-list-new-arraylist-instead-of-arraylist-list-n)

<details>
<summary>๐ŸŒฑ step2. ์ž๋ฐ” ๋กœ๋˜ 2๋‹จ๊ณ„ - ๋ณด๋„ˆ์Šค ๋ฒˆํ˜ธ ์ถ”๊ฐ€</summary>
- pair programming (hanse, sally)

#### ๊ธฐ๋Šฅ์š”๊ตฌ์‚ฌํ•ญ

- [x] ๋กœ๋˜ ๊ตฌ์ž… ๊ธˆ์•ก์„ ์ž…๋ ฅํ•˜๋ฉด ๊ตฌ์ž… ๊ธˆ์•ก์— ํ•ด๋‹นํ•˜๋Š” ๋กœ๋˜๋ฅผ ๋ฐœ๊ธ‰ํ•ด์•ผ ํ•œ๋‹ค.
- [x] ๋กœ๋˜ 1์žฅ์˜ ๊ฐ€๊ฒฉ์€ 1000์›์ด๋‹ค.
- [x] ๋‹น์ฒจ ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅ๋ฐ›์•„์„œ ์ˆ˜์ต๋ฅ ์„ ์ถœ๋ ฅํ•œ๋‹ค.
- [x] ๊ธฐ๋Œ€ ์ˆ˜์ต์€ ๋™์ž‘ ์˜ˆ์‹œ๋ฅผ ์ฐธ๊ณ ํ•˜์ž.
- [x] 2๋“ฑ์„ ์œ„ํ•ด ์ถ”๊ฐ€ ๋ฒˆํ˜ธ๋ฅผ ํ•˜๋‚˜ ๋” ์ถ”์ฒจํ•œ๋‹ค. ๋‹น์ฒจ ํ†ต๊ณ„์— 2๋“ฑ๋„ ์ถ”๊ฐ€ํ•ด์•ผ ํ•œ๋‹ค.



#### ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์š”๊ตฌ์‚ฌํ•ญ

- [x] indent(์ธ๋ดํŠธ, ๋“ค์—ฌ์“ฐ๊ธฐ) depth๋ฅผ 1๋‹จ๊ณ„๋กœ ๊ตฌํ˜„ํ•œ๋‹ค.
- [x] depth์˜ ๊ฒฝ์šฐ if๋ฌธ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ 1๋‹จ๊ณ„์˜ depth๊ฐ€ ์ฆ๊ฐ€ํ•œ๋‹ค. if๋ฌธ ์•ˆ์— while๋ฌธ์„ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด depth๊ฐ€ 2๋‹จ๊ณ„๊ฐ€ ๋œ๋‹ค.
- [x] else๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ๋งˆ๋ผ.
- [x] ๋ฉ”์†Œ๋“œ์˜ ํฌ๊ธฐ๊ฐ€ ์ตœ๋Œ€ 10๋ผ์ธ์„ ๋„˜์ง€ ์•Š๋„๋ก ๊ตฌํ˜„ํ•œ๋‹ค.
- [x] method๊ฐ€ ํ•œ ๊ฐ€์ง€ ์ผ๋งŒ ํ•˜๋„๋ก ์ตœ๋Œ€ํ•œ ์ž‘๊ฒŒ ๋งŒ๋“ค์–ด๋ผ.
- [x] ArrayList๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๊ตฌํ˜„ํ•œ๋‹ค.

- [x] enum์„ ์ ์šฉํ•ด ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ๊ตฌํ˜„ํ•œ๋‹ค.

#### ์ถœ๋ ฅ ๊ฒฐ๊ณผ

<img src="https://user-images.githubusercontent.com/92699009/155276313-d1260c5c-de96-4875-9a05-bf43b59c10b9.png">
<img src="https://user-images.githubusercontent.com/92699009/155632776-f8de735e-2021-4985-8104-3e79c7f7317c.PNG">

</details>
29 changes: 29 additions & 0 deletions src/LottoApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import static view.Input.*;
import static view.Output.*;

import java.util.List;

import domains.user.LottoMachine;
import domains.user.Lottos;
import domains.user.Tickets;
import domains.winning.Ranking;
import domains.user.UserLotto;
import view.PurchasedLotto;

public class LottoApplication {
private static LottoMachine lottoMachine = new LottoMachine();
private static Lottos lottos = new Lottos();
private static UserLotto userLotto = new UserLotto(lottoMachine, lottos);
Comment on lines +14 to +16

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด ๋ถ€๋ถ„์„ ์–ด๋–ป๊ฒŒ ๊ฐœ์„ ํ•˜๋ฉด ์ข‹์„์ง€ 3๋‹จ๊ณ„์—์„œ ๊ณ ๋ฏผํ•ด์ฃผ์„ธ์š”~

ํžŒํŠธ: LottoGame ๋ถ„๋ฆฌ, ์˜์กด์„ฑ ์ฃผ์ž…

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์œผ-์Œ.... ์–ด๋ ต์ง€๋งŒ, ์•Œ ๊ฒƒ๋„ ๊ฐ™๊ณ ... @_@๊ณ ๋ฏผ ํ•ด์„œ ๊ฐœ์„ ๋˜๋„๋ก ๋…ธ๋ ฅํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
3๋‹จ๊ณ„ ์ง„ํ–‰ํ•˜๋ฉด์„œ ์˜คํ† ,์ˆ˜๋™๋งŒ di๋กœ ํ–ˆ๋Š”๋ฐ๋„, ๋ณด์ง€ ๋ชปํ•œ ๋ถ€๋ถ„์ด ์žˆ๋Š” ๊ฑฐ ๊ฐ™์•„์š”.
์•Œ๋ ค์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.๐Ÿฅ‡


public static void main(String[] args) {
PurchasedLotto purchasedLotto = purchaseLotto();

Tickets totalLottos = userLotto.getTickets(purchasedLotto);
showLottos(totalLottos);

Ranking ranking = userLotto.getRankingFromWinningNumbers(inputWinningNumbers(), getBonusNumber());
getResultOfLotto(ranking, purchasedLotto.getPurchaseAmount());

scanClose();
}
}
44 changes: 0 additions & 44 deletions src/Main.java

This file was deleted.

40 changes: 0 additions & 40 deletions src/domains/Lotto.java

This file was deleted.

43 changes: 0 additions & 43 deletions src/domains/Lottos.java

This file was deleted.

92 changes: 0 additions & 92 deletions src/domains/Ranking.java

This file was deleted.

25 changes: 0 additions & 25 deletions src/domains/Winnings.java

This file was deleted.

53 changes: 53 additions & 0 deletions src/domains/user/Lotto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package domains.user;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

import domains.winning.BonusWinningNumbers;
import domains.winning.Ranking;

public class Lotto {
public static final int MINIMUM_NUMBER_OF_WINNING = 3;
public static final String ERROR_OF_LOTTO_PARAMS = "error of lotto params";
private final List<Integer> sixNumbers;

public Lotto(List<Integer> sixNumbers) {
if (Objects.isNull(sixNumbers)) {
throw new IllegalArgumentException(ERROR_OF_LOTTO_PARAMS);
}
if (sixNumbers.size() < 6) {
throw new IllegalArgumentException(ERROR_OF_LOTTO_PARAMS);
}
Collections.sort(sixNumbers);
this.sixNumbers = sixNumbers;
}

public void recordRanking(BonusWinningNumbers winningNumbers, Ranking ranking){
boolean checkedBonus = false;
List<Integer> winning = winningNumbers.getNumbers();
int winningCount = countWinningNumber(winning);

if (winningCount >= MINIMUM_NUMBER_OF_WINNING) {
checkedBonus = this.getBonus(winningNumbers.getBonus());
}
ranking.record(checkedBonus, winningCount);
}

private int countWinningNumber(List<Integer> winning) {
return Math.toIntExact(winning.stream()
.filter(winningNumber -> this.sixNumbers.contains(winningNumber))
.count());
}

private int getCount(int count, Integer winningNumber) {
if (sixNumbers.contains(winningNumber)) {
count++;
}
return count;
}

public boolean getBonus(int bonusNumber) {
return sixNumbers.contains(bonusNumber);
}
}
Loading