-
Notifications
You must be signed in to change notification settings - Fork 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
๐ [hanse & sally] ๋ก๋ 2๋จ๊ณ - ๋ณด๋์ค ๋ฒํธ ์ถ๊ฐ #45
base: sally-ksh
Are you sure you want to change the base?
Changes from 13 commits
f0573f7
d069d61
8d41897
d69a5ee
141f826
696896e
ec5169b
d7ca355
72bc927
b9df53d
7ac4a2b
ee3deaa
79bfcec
73388b2
8271d2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import static views.Input.*; | ||
import static views.Output.*; | ||
|
||
import java.util.List; | ||
|
||
import domains.users.LottoMachine; | ||
import domains.users.Lottos; | ||
import domains.winnings.Ranking; | ||
import domains.users.UserLotto; | ||
import views.PurchasedLotto; | ||
|
||
public class LottoApplication { | ||
private static LottoMachine lottoMachine = new LottoMachine(); | ||
private static Lottos lottos = new Lottos(); | ||
private static UserLotto userLotto = new UserLotto(lottoMachine, lottos); | ||
|
||
public static void main(String[] args) { | ||
PurchasedLotto purchasedLotto = purchaseLotto(); | ||
|
||
List<List<Integer>> totalLottos = userLotto.getTickets(purchasedLotto); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2์ฐจ์ ๋ฐฐ์ด์ ์ฐจ์ด์ ๊ณผ ๋ฆฌ์คํธ์ ์ฅ์ ์ ์๊ณ ๋ฆฌ์คํธ๋ฅผ ์ ํํด์ ์ฌ์ฉํ๊ฑด์ง์ ๋ํ๊ฑธ ๋ง์ํ์๋ ๊ฑธ๊น์? ์ด๋ค ์๋ฏธ์ธ์ง ๋ชฐ๋ผ ์ฌ์ญ๋๋คใ ใ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๋ค ์ฐจ์ด์ ์ด ์๋ค๋๊ฒ ์ ๋ต์ด์์ด์. ใ
ใ
|
||
showLottos(totalLottos); | ||
|
||
List<Integer> inputValueOfWinningNumbers = inputWinningNumbers(); | ||
int bonusNumber = getBonusNumber(); | ||
|
||
Ranking ranking = userLotto.getRankingFromWinningNumbers(inputValueOfWinningNumbers, bonusNumber); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ranking ranking = userLotto.getRankingFromWinningNumbers(inputWinningNumbers(), getBonusNumber()); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๊ฐ์ฒดํ์
๋ฐํ์ ๊ฒฝ์ฐ๋ ๋ช
์์ ์ผ๋ก ์ ์ด์ฃผ๋ ๊ฒ ์์ ์ฑ ๋ฑ์์ ์ข๋ค๊ณ ์๊ณ ์์์ต๋๋ค. ํน์ ๋ฌธ์ ๋๊ฑฐ๋ ์ ์ข์ ์ด์ ๊ฐ ์๋ค๋ฉด ๊ตฌ์ฒด์ ์ผ๋ก ์๊ณ ์ถ์ด์์. |
||
getResultOfLotto(ranking, purchasedLotto.getPurchaseAmount()); | ||
|
||
scanClose(); | ||
} | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,4 +1,4 @@ | ||||||||||||
package domains; | ||||||||||||
package domains.users; | ||||||||||||
|
||||||||||||
import java.util.Collections; | ||||||||||||
import java.util.List; | ||||||||||||
|
@@ -23,7 +23,7 @@ public List<Integer> numbers() { | |||||||||||
return this.sixNumbers; | ||||||||||||
} | ||||||||||||
|
||||||||||||
public int numberOfWinnings(List<Integer> winningNumbers){ | ||||||||||||
public int countNumberOfWinnings(List<Integer> winningNumbers){ | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||
int count = 0; | ||||||||||||
for (Integer winningNumber : winningNumbers) { | ||||||||||||
count = getCount(count, winningNumber); | ||||||||||||
|
@@ -37,4 +37,11 @@ private int getCount(int count, Integer winningNumber) { | |||||||||||
} | ||||||||||||
return count; | ||||||||||||
} | ||||||||||||
|
||||||||||||
public boolean getBonus(int bonusNumber) { | ||||||||||||
if (sixNumbers.contains(bonusNumber)){ | ||||||||||||
return true; | ||||||||||||
} | ||||||||||||
return false; | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์ด๋ ๊ฒ ๋ฐ๊ฟ ์ ์์ง ์์๊น์
Suggested change
|
||||||||||||
} | ||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package domains; | ||
package domains.users; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ํจํค์ง๋ช ์ ๋ณต์ํ์ ์ ์ฐ์ง ์์ต๋๋ค. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ํ์ฌ๋ ํ๋ช
์ ์
๋ ฅ๋ง ๋ฐ์์ ๋ณต์ํ ์ฐ์ง ์๋๊ฒ ๋ง๊ณ , ์คํ๋ง์ ๊ฒฝ์ฐ์๋ ์ฌ๋ฌ ์ฌ์ฉ์ ์ ๋ณด๋ฅผ ๋ค๋ฃจ๋ ๋ณต์ํ์ ์ฐ๋๊ฒ ๋ง๋ค๊ณ ์๊ฐํ๋ฉด ๋ ๊น์? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์ผ๋จ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๋ค, ๋ง์ํด ์ฃผ์ ๋ถ๋ถ์ ์ดํดํ ์ ์์๊ฑฐ ๊ฐ์์. |
||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
package domains; | ||
|
||
import static java.util.stream.Collectors.*; | ||
package domains.users; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import domains.winnings.BonusWinningNumbers; | ||
import domains.winnings.Ranking; | ||
|
||
public class Lottos { | ||
public static final int MINIMUM_NUMBER_OF_WINNING = 3; | ||
private ArrayList<Lotto> lottos = new ArrayList<>(); | ||
|
@@ -14,11 +15,18 @@ public Lottos() { | |
} | ||
|
||
public List<List<Integer>> getTotalLottos(ArrayList<ArrayList<Integer>> tickets) { | ||
toLottos(tickets); | ||
|
||
return getPurchasedLottos(); | ||
} | ||
|
||
private void toLottos(ArrayList<ArrayList<Integer>> tickets) { | ||
for (ArrayList<Integer> ticket : tickets) { | ||
this.purchased(ticket); | ||
} | ||
} | ||
|
||
private List<List<Integer>> getPurchasedLottos() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๋น์ฒจ๋ฒํธ ๋ฆฌ์คํธ๋ฅผ ๋ณด๊ดํ ๋งํ ๊ฐ์ฒด๋ฅผ ์ค๊ณํด์ ๊ทธ ๊ฐ์ฒด์ ๋ฆฌ์คํธ๋ก ์ ๋ฌํด์ฃผ๋ฉด ๋ ์ข์ํ ๋ฐ์? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๋ต, ๋ง์ต๋๋ค. |
||
List<List<Integer>> purchasedLottos = new ArrayList<>(); | ||
for (Lotto lotto : this.lottos) { | ||
List<Integer> numbers = lotto.numbers(); | ||
|
@@ -32,12 +40,17 @@ private void purchased(ArrayList<Integer> pickedNumber){ | |
this.lottos.add(lotto); | ||
} | ||
|
||
public List<Integer> numberOfWinningAboveThree(List<Integer> winningNumbers) { | ||
List<Integer> resultOfLottos = this.lottos.stream() | ||
.mapToInt(lotto -> lotto.numberOfWinnings(winningNumbers)) | ||
.filter(value -> value >= MINIMUM_NUMBER_OF_WINNING) | ||
.boxed() | ||
.collect(toList()); | ||
return resultOfLottos; | ||
public Ranking getNumberOfWinningAboveThree(BonusWinningNumbers winningNumbers) { | ||
Ranking ranking = new Ranking(); | ||
List<Integer> winning = winningNumbers.getNumbers(); | ||
|
||
for (Lotto lotto : lottos) { | ||
int winningCount = lotto.countNumberOfWinnings(winning); | ||
if (winningCount >= MINIMUM_NUMBER_OF_WINNING) { | ||
boolean checkedBonus = lotto.getBonus(winningNumbers.getBonus()); | ||
ranking.record(checkedBonus, winningCount); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์ค๊ฐ์ WinningNumber๋ก ๋ถ๋ฆฌํ๊ณ , Ranking ๋ฐํ ๋ฑ ๊ฐ์ ํ๋ฉด์, ์์ผ๊ฐ ์ข์์ง๊ณ , ์ข ๋ ๋ถ๋ช
ํ๊ฒ ์ ๋ฆฌํ์ง ๋ชป ํ๊ฑฐ ๊ฐ์์. |
||
} | ||
return ranking; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package domains; | ||
package domains.users; | ||
|
||
public class Money { | ||
private static final String WON = "์"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package domains.users; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import domains.winnings.BonusWinningNumbers; | ||
import domains.winnings.Ranking; | ||
import views.PurchasedLotto; | ||
|
||
public class UserLotto { | ||
private final LottoMachine lottoMachine; | ||
private final Lottos lottos; | ||
|
||
public UserLotto(LottoMachine lottoMachine, Lottos lottos) { | ||
this.lottoMachine = lottoMachine; | ||
this.lottos = lottos; | ||
} | ||
|
||
public List<List<Integer>> getTickets(PurchasedLotto purchasedLotto) { | ||
ArrayList<ArrayList<Integer>> tickets = lottoMachine.getTicket(purchasedLotto.getNumberOfTicket()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์๊ตฌ์ฌํญ ์ค์ "ArrayList๋ฅผ ์ฌ์ฉํด์ ๊ตฌํํ๋ค." ๊ฐ ์์๋๋ฐ ๋จ์ํ๊ฒ ๋ฐํํ์
๊น์ง ์จ์ผ ํ๋ค๊ณ ์๊ฐํ๊ณ ์์
ํ๋๊ฑฐ ๊ฐ์ต๋๋ค. ๋ ๋ณด๋ค ์ข์ ์ง์ ์๊ฒ ๋ ๊ฑฐ ๊ฐ์์. ๊ฐ์ฌํฉ๋๋ค. |
||
return lottos.getTotalLottos(tickets); | ||
} | ||
|
||
public Ranking getRankingFromWinningNumbers(List<Integer> inputValueOfWinningNumbers, int bonusNumber) { | ||
BonusWinningNumbers winningNumbers = new BonusWinningNumbers(inputValueOfWinningNumbers, bonusNumber); | ||
Ranking ranking = lottos.getNumberOfWinningAboveThree(winningNumbers); | ||
return ranking; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package domains.winnings; | ||
|
||
import java.util.List; | ||
|
||
public class BonusWinningNumbers extends WinningNumbers{ | ||
private final int bonus; | ||
|
||
public BonusWinningNumbers(List<Integer> winningNumbers, int bonus) { | ||
super(winningNumbers); | ||
this.bonus = bonus; | ||
} | ||
|
||
public int getBonus() { | ||
return bonus; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ด ๋ถ๋ถ์ ์ด๋ป๊ฒ ๊ฐ์ ํ๋ฉด ์ข์์ง 3๋จ๊ณ์์ ๊ณ ๋ฏผํด์ฃผ์ธ์~
ํํธ:
LottoGame
๋ถ๋ฆฌ, ์์กด์ฑ ์ฃผ์There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ผ-์.... ์ด๋ ต์ง๋ง, ์ ๊ฒ๋ ๊ฐ๊ณ ... @_@๊ณ ๋ฏผ ํด์ ๊ฐ์ ๋๋๋ก ๋ ธ๋ ฅํ๊ฒ ์ต๋๋ค.
3๋จ๊ณ ์งํํ๋ฉด์ ์คํ ,์๋๋ง di๋ก ํ๋๋ฐ๋, ๋ณด์ง ๋ชปํ ๋ถ๋ถ์ด ์๋ ๊ฑฐ ๊ฐ์์.
์๋ ค์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค.๐ฅ