From 3fa5d556e503702355b9edcce94da3c546e5bac1 Mon Sep 17 00:00:00 2001 From: ichangyu Date: Fri, 2 Apr 2021 12:17:46 +0900 Subject: [PATCH 1/8] =?UTF-8?q?feat:=20=EB=A1=9C=EB=98=90=201=EB=8B=A8?= =?UTF-8?q?=EA=B3=84-=EC=9E=90=EB=8F=99=EB=AF=B8=EC=85=98=20=EC=A0=9C?= =?UTF-8?q?=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/LottoApplication.java | 51 ++++++++++++++ src/main/java/domain/EnumWinningStatus.java | 59 ++++++++++++++++ src/main/java/domain/LottoFactory.java | 23 +++++++ src/main/java/domain/LottoMachine.java | 68 +++++++++++++++++++ src/main/java/domain/Profit.java | 21 ++++++ src/main/java/domain/WinningStatus.java | 31 +++++++++ src/main/java/{ => domain}/empty.txt | 0 .../NotValidLottoLengthException.java | 9 +++ .../LastWeekWinningBonusBall.java | 13 ++++ .../LastWeekWinningLotto.java | 18 +++++ src/main/java/domain/lottoticket/Lotto.java | 7 ++ .../java/domain/lottoticket/LottoTicket.java | 25 +++++++ src/main/java/domain/lottoticket/Lottos.java | 15 ++++ .../lottoticket/NumberOfLottoTicket.java | 25 +++++++ .../LottoWinningBonusBallResult.java | 15 ++++ .../LottoWinningResult.java | 15 ++++ .../strategy/RandomLottoNumberStrategy.java | 33 +++++++++ src/main/java/ui/Printer.java | 42 ++++++++++++ src/main/java/ui/Receiver.java | 36 ++++++++++ 19 files changed, 506 insertions(+) create mode 100644 src/main/java/LottoApplication.java create mode 100644 src/main/java/domain/EnumWinningStatus.java create mode 100644 src/main/java/domain/LottoFactory.java create mode 100644 src/main/java/domain/LottoMachine.java create mode 100644 src/main/java/domain/Profit.java create mode 100644 src/main/java/domain/WinningStatus.java rename src/main/java/{ => domain}/empty.txt (100%) create mode 100644 src/main/java/domain/exception/NotValidLottoLengthException.java create mode 100644 src/main/java/domain/lastweekwinninglotto/LastWeekWinningBonusBall.java create mode 100644 src/main/java/domain/lastweekwinninglotto/LastWeekWinningLotto.java create mode 100644 src/main/java/domain/lottoticket/Lotto.java create mode 100644 src/main/java/domain/lottoticket/LottoTicket.java create mode 100644 src/main/java/domain/lottoticket/Lottos.java create mode 100644 src/main/java/domain/lottoticket/NumberOfLottoTicket.java create mode 100644 src/main/java/domain/lottowinningresult/LottoWinningBonusBallResult.java create mode 100644 src/main/java/domain/lottowinningresult/LottoWinningResult.java create mode 100644 src/main/java/domain/strategy/RandomLottoNumberStrategy.java create mode 100644 src/main/java/ui/Printer.java create mode 100644 src/main/java/ui/Receiver.java diff --git a/src/main/java/LottoApplication.java b/src/main/java/LottoApplication.java new file mode 100644 index 0000000..fdfe006 --- /dev/null +++ b/src/main/java/LottoApplication.java @@ -0,0 +1,51 @@ +import domain.LottoMachine; +import domain.Profit; +import domain.WinningStatus; +import domain.lastweekwinninglotto.LastWeekWinningBonusBall; +import domain.lastweekwinninglotto.LastWeekWinningLotto; +import domain.lottoticket.LottoTicket; +import domain.lottoticket.Lottos; +import domain.lottoticket.NumberOfLottoTicket; +import domain.strategy.RandomLottoNumberStrategy; +import ui.Printer; +import ui.Receiver; + +import java.util.ArrayList; +import java.util.List; + +public class LottoApplication { + private final Printer printer = new Printer(); + private final Receiver receiver = new Receiver(); + private static LottoMachine lottoMachine = new LottoMachine(); + private final RandomLottoNumberStrategy randomLottoNumberStrategy = new RandomLottoNumberStrategy(); + + public void run() { + printer.requestPurchaseAmount(); + NumberOfLottoTicket numberOfLottoTicket = new NumberOfLottoTicket(receiver.receiveLottoTotalAmount()); + Lottos lottos = makeLottos(numberOfLottoTicket); + printer.printAllLotto(lottos); + printer.requestLastWeekLottoWinningNumber(); + List LastWeekLottoWinningNumbers = receiver.receiveLastWeekLottoWinningNumbers(); + LastWeekWinningLotto lastWeekWinningLotto = new LastWeekWinningLotto(LastWeekLottoWinningNumbers); + printer.requestLottoBonusBallNumber(); + LastWeekWinningBonusBall lastWeekWinningBonusBall = new LastWeekWinningBonusBall(receiver.receiveLottoBonusBallNumber()); + ArrayList getLottoPrices = lottoMachine.Discriminator(lottos, lastWeekWinningLotto, lastWeekWinningBonusBall, numberOfLottoTicket); + Profit profit = new Profit(getLottoPrices); + printer.printLottoProfit(profit.getCalculatedProfit(numberOfLottoTicket)); + } + + private Lottos makeLottos(NumberOfLottoTicket numberOfLottoTicket) { + ArrayList lottoDummy = new ArrayList<>(); + for (int i = 0; i < numberOfLottoTicket.getNumberOfLottoTicket(); i++) { + LottoTicket lotto = new LottoTicket(randomLottoNumberStrategy.getRandomLottoNumbers()); + lottoDummy.add(lotto); + } + Lottos lottos = new Lottos(lottoDummy); + return lottos; + } + + public static void main(String[] args) { + LottoApplication app = new LottoApplication(); + app.run(); + } +} \ No newline at end of file diff --git a/src/main/java/domain/EnumWinningStatus.java b/src/main/java/domain/EnumWinningStatus.java new file mode 100644 index 0000000..671fe6e --- /dev/null +++ b/src/main/java/domain/EnumWinningStatus.java @@ -0,0 +1,59 @@ +package domain; + +import domain.lottoticket.NumberOfLottoTicket; +import domain.lottowinningresult.LottoWinningBonusBallResult; +import domain.lottowinningresult.LottoWinningResult; +import ui.Printer; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +public class EnumWinningStatus { + private static final int NOT_MATCH_LOTTO = 0; + private ArrayList lottoPrices = new ArrayList<>(); + private Map mappingLottoWithBonusBall = new HashMap<>(); + private Printer printer = new Printer(); + + public ArrayList getLottoPrices(LottoFactory lottoFactory, NumberOfLottoTicket numberOfLottoTicket){ + LottoWinningResult lottoWinningResults = lottoFactory.getLottoWinningResult(); + LottoWinningBonusBallResult lottoWinningBonusBallResult = lottoFactory.getLottoWinningBonusBallResult(); + + for (int i = 0; i < numberOfLottoTicket.getNumberOfLottoTicket(); i++) { + int lottoMatchedNumber = lottoWinningResults.getLottoWinningResult().get(i); + Boolean lottoBonusBallNumber = lottoWinningBonusBallResult.getLottoWinningBonusBallResult().get(i); + getWinningLottoTicketPrices(lottoMatchedNumber, lottoBonusBallNumber); + } + printer.printAllMatchedLottoResult(getMappingLottoWithBonusBall()); + return lottoPrices; + } + + private void getWinningLottoTicketPrices(int lottoMatchedNumber, boolean lottoBonusBallNumber) { + for(WinningStatus winningStatus: WinningStatus.values()){ + int matchedWinningNumberCount = winningStatus.getMatchCount(); + boolean isMatchedBonusBallCount = winningStatus.hasBonusBall(); + makeWinningLottoTicket(lottoMatchedNumber, matchedWinningNumberCount, isMatchedBonusBallCount, lottoBonusBallNumber, winningStatus); + } + } + + private void makeWinningLottoTicket( + int lottoMatchedNumber, + int matchedWinningNumberCount, + boolean isMatchedBonusBallCount, + boolean lottoBonusBallNumber, + WinningStatus winningStatus + ){ + if((lottoMatchedNumber == matchedWinningNumberCount) && (isMatchedBonusBallCount == lottoBonusBallNumber)){ + lottoPrices.add(winningStatus); + } + } + + private Map getMappingLottoWithBonusBall() { + for (WinningStatus key: lottoPrices + ) { + mappingLottoWithBonusBall.put(key, mappingLottoWithBonusBall.getOrDefault(key, 0)+1); + } + return mappingLottoWithBonusBall; + } + +} \ No newline at end of file diff --git a/src/main/java/domain/LottoFactory.java b/src/main/java/domain/LottoFactory.java new file mode 100644 index 0000000..fb17f23 --- /dev/null +++ b/src/main/java/domain/LottoFactory.java @@ -0,0 +1,23 @@ +package domain; + +import domain.lottowinningresult.LottoWinningBonusBallResult; +import domain.lottowinningresult.LottoWinningResult; + +public class LottoFactory { + private LottoWinningResult lottoWinningResult; + private LottoWinningBonusBallResult lottoWinningBonusBallResult; + + public LottoFactory(LottoWinningResult lottoWinningResults, LottoWinningBonusBallResult lottoWinningBonusBallResults){ + this.lottoWinningResult = lottoWinningResults; + this.lottoWinningBonusBallResult = lottoWinningBonusBallResults; + } + + public LottoWinningResult getLottoWinningResult(){ + return this.lottoWinningResult; + } + + public LottoWinningBonusBallResult getLottoWinningBonusBallResult(){ + return this.lottoWinningBonusBallResult; + } + +} diff --git a/src/main/java/domain/LottoMachine.java b/src/main/java/domain/LottoMachine.java new file mode 100644 index 0000000..bcce726 --- /dev/null +++ b/src/main/java/domain/LottoMachine.java @@ -0,0 +1,68 @@ +package domain; + +import domain.lastweekwinninglotto.LastWeekWinningBonusBall; +import domain.lastweekwinninglotto.LastWeekWinningLotto; +import domain.lottoticket.LottoTicket; +import domain.lottoticket.Lottos; +import domain.lottoticket.NumberOfLottoTicket; +import domain.lottowinningresult.LottoWinningBonusBallResult; +import domain.lottowinningresult.LottoWinningResult; + +import java.util.ArrayList; +import java.util.List; + +public class LottoMachine { + EnumWinningStatus enumWinningStatus = new EnumWinningStatus(); + ArrayList lottoWinningResults = new ArrayList<>(); + ArrayList lottoWinningBonusBallResults = new ArrayList<>(); + + public ArrayList Discriminator( + Lottos lottos, + LastWeekWinningLotto lastWeekWinningLotto, + LastWeekWinningBonusBall lastWeekWinningBonusBall, + NumberOfLottoTicket numberOfLottoTicket + ){ + for (LottoTicket lotto : lottos.getLottos()) + { + List lottoMatchedResult = getMatchLottoNumber(lotto, lastWeekWinningLotto); + Boolean lottoMatchedBonusBallResult = getMatchLottoBonusBallNumber(lotto, lastWeekWinningBonusBall); + int matchLottoNumberCount = getMatchLottoNumberCount(lottoMatchedResult); + lottoWinningResults.add(matchLottoNumberCount); + lottoWinningBonusBallResults.add(lottoMatchedBonusBallResult); + } + LottoFactory lottoFactory = createLottoFactory(lottoWinningResults, lottoWinningBonusBallResults); + return enumWinningStatus.getLottoPrices(lottoFactory, numberOfLottoTicket); + } + + private LottoFactory createLottoFactory(ArrayList lottoWinningResults, ArrayList lottoWinningBonusBallResults) { + LottoWinningBonusBallResult lottoWinningBonusBallResult = new LottoWinningBonusBallResult(lottoWinningBonusBallResults); + LottoWinningResult winningResult = new LottoWinningResult(lottoWinningResults); + + LottoFactory lottoFactory = new LottoFactory(winningResult, lottoWinningBonusBallResult); + return lottoFactory; + } + + private int getMatchLottoNumberCount(List lottoMatchedResult){ + return (int) lottoMatchedResult.stream().filter(index-> (index)).count(); + } + + private List getMatchLottoNumber(LottoTicket lotto, LastWeekWinningLotto lastWeekWinningLotto){ + List lottoList = lotto.getLotto(); + List lastWeekWinningLottos = lastWeekWinningLotto.getLotto(); + ArrayList lottoMatchedResult = new ArrayList<>(); + + for (int winningLottoNumber = 0; winningLottoNumber < lastWeekWinningLottos.size(); winningLottoNumber++) { + Boolean isMatchLottoNumber = lottoList.contains(lastWeekWinningLottos.get(winningLottoNumber)); + lottoMatchedResult.add(isMatchLottoNumber); + } + return lottoMatchedResult; + } + + private Boolean getMatchLottoBonusBallNumber(LottoTicket lotto, LastWeekWinningBonusBall lastWeekWinningBonusBall) { + List lottoBonusBalls = lotto.getLotto(); + int lastWeekWinningBonusBalls = lastWeekWinningBonusBall.getLastWeekWinningBonusBall(); + Boolean isMatchLottoNumber = lottoBonusBalls.contains(lastWeekWinningBonusBalls); + return isMatchLottoNumber; + + } +} \ No newline at end of file diff --git a/src/main/java/domain/Profit.java b/src/main/java/domain/Profit.java new file mode 100644 index 0000000..dcf305b --- /dev/null +++ b/src/main/java/domain/Profit.java @@ -0,0 +1,21 @@ +package domain; + +import domain.lottoticket.NumberOfLottoTicket; + +import java.util.List; + +public class Profit { + private static int totalLottoPrice; + public Profit(List lottoPrices) { + int sumLottoPrices = sumLottoPrices(lottoPrices); + totalLottoPrice = sumLottoPrices; + } + + private int sumLottoPrices(List lottoPrices){ + return lottoPrices.stream().mapToInt(WinningStatus::getWinningMoney).sum(); + } + + public float getCalculatedProfit(NumberOfLottoTicket numberOfLottoTicket) { + return (float) totalLottoPrice / numberOfLottoTicket.getMoney(); + } +} \ No newline at end of file diff --git a/src/main/java/domain/WinningStatus.java b/src/main/java/domain/WinningStatus.java new file mode 100644 index 0000000..0c4d1e7 --- /dev/null +++ b/src/main/java/domain/WinningStatus.java @@ -0,0 +1,31 @@ +package domain; + +public enum WinningStatus { + SIX_MATCH(6, false, 2000000000), + FIVE_MATCH_WITH_BONUS_BALL(5, true, 30000000), + FIVE_MATCH(5, false, 1500000), + FOUR_MATCH(4, false, 50000), + THREE_MATCH(3, false, 5000); + + private final int matchCount; + private final int winningMoney; + private final boolean BonusBall; + + WinningStatus(int matchCount, boolean BonusBall, int winningMoney){ + this.matchCount = matchCount; + this.winningMoney = winningMoney; + this.BonusBall = BonusBall; + } + + public int getMatchCount() { + return this.matchCount; + } + + public boolean hasBonusBall() { + return this.BonusBall; + } + + public int getWinningMoney() { + return this.winningMoney; + } +} \ No newline at end of file diff --git a/src/main/java/empty.txt b/src/main/java/domain/empty.txt similarity index 100% rename from src/main/java/empty.txt rename to src/main/java/domain/empty.txt diff --git a/src/main/java/domain/exception/NotValidLottoLengthException.java b/src/main/java/domain/exception/NotValidLottoLengthException.java new file mode 100644 index 0000000..19e90ac --- /dev/null +++ b/src/main/java/domain/exception/NotValidLottoLengthException.java @@ -0,0 +1,9 @@ +package domain.exception; + +public class NotValidLottoLengthException extends RuntimeException { + private static final String MESSAGE = "번호는 6개를 입력해야 합니다."; + + public NotValidLottoLengthException() { + super(MESSAGE); + } +} \ No newline at end of file diff --git a/src/main/java/domain/lastweekwinninglotto/LastWeekWinningBonusBall.java b/src/main/java/domain/lastweekwinninglotto/LastWeekWinningBonusBall.java new file mode 100644 index 0000000..7599b48 --- /dev/null +++ b/src/main/java/domain/lastweekwinninglotto/LastWeekWinningBonusBall.java @@ -0,0 +1,13 @@ +package domain.lastweekwinninglotto; + +public class LastWeekWinningBonusBall { + + private final int bonusBall; + public LastWeekWinningBonusBall(int bonusBall){ + this.bonusBall = bonusBall; + } + + public int getLastWeekWinningBonusBall(){ + return this.bonusBall; + } +} \ No newline at end of file diff --git a/src/main/java/domain/lastweekwinninglotto/LastWeekWinningLotto.java b/src/main/java/domain/lastweekwinninglotto/LastWeekWinningLotto.java new file mode 100644 index 0000000..742d857 --- /dev/null +++ b/src/main/java/domain/lastweekwinninglotto/LastWeekWinningLotto.java @@ -0,0 +1,18 @@ +package domain.lastweekwinninglotto; + +import domain.lottoticket.Lotto; + +import java.util.List; + +public class LastWeekWinningLotto implements Lotto { + private final List winningLotto; + + public LastWeekWinningLotto(List winningLotto){ + this.winningLotto = winningLotto; + } + + @Override + public List getLotto(){ + return this.winningLotto; + } +} \ No newline at end of file diff --git a/src/main/java/domain/lottoticket/Lotto.java b/src/main/java/domain/lottoticket/Lotto.java new file mode 100644 index 0000000..e6c49a4 --- /dev/null +++ b/src/main/java/domain/lottoticket/Lotto.java @@ -0,0 +1,7 @@ +package domain.lottoticket; + +import java.util.List; + +public interface Lotto { + public List getLotto(); +} \ No newline at end of file diff --git a/src/main/java/domain/lottoticket/LottoTicket.java b/src/main/java/domain/lottoticket/LottoTicket.java new file mode 100644 index 0000000..1e4e5a8 --- /dev/null +++ b/src/main/java/domain/lottoticket/LottoTicket.java @@ -0,0 +1,25 @@ +package domain.lottoticket; + +import domain.exception.*; +import java.util.List; + +public class LottoTicket implements Lotto{ + private static final int LOTTO_NUMBER_COUNT = 6; + private final List numbers; + + public LottoTicket(List numbers ) { + checkLottoLength(numbers); + this.numbers = numbers; + } + + private void checkLottoLength(List numbers){ + if(numbers.size() !=LOTTO_NUMBER_COUNT){ + throw new NotValidLottoLengthException(); + } + } + @Override + public List getLotto(){ + return this.numbers; + } + +} \ No newline at end of file diff --git a/src/main/java/domain/lottoticket/Lottos.java b/src/main/java/domain/lottoticket/Lottos.java new file mode 100644 index 0000000..2ce7ded --- /dev/null +++ b/src/main/java/domain/lottoticket/Lottos.java @@ -0,0 +1,15 @@ +package domain.lottoticket; + +import java.util.List; + +public class Lottos { + private final List lotto; + + public Lottos(List lotto ) { + this.lotto = lotto; + } + + public List getLottos() { + return this.lotto; + } +} \ No newline at end of file diff --git a/src/main/java/domain/lottoticket/NumberOfLottoTicket.java b/src/main/java/domain/lottoticket/NumberOfLottoTicket.java new file mode 100644 index 0000000..74f3b4f --- /dev/null +++ b/src/main/java/domain/lottoticket/NumberOfLottoTicket.java @@ -0,0 +1,25 @@ +package domain.lottoticket; + +public class NumberOfLottoTicket { + private final static int LOTTO_PRICE = 1000; + private final int tickets; + private final int money; + + public NumberOfLottoTicket(int money) { + this.tickets = setNumberOfLottoTickets(money); + this.money = money; + } + + // naming 바꾸기 + private int setNumberOfLottoTickets(int money) { + return money / LOTTO_PRICE; + } + + public int getNumberOfLottoTicket() { + return this.tickets; + } + + public int getMoney() { + return this.money; + } +} \ No newline at end of file diff --git a/src/main/java/domain/lottowinningresult/LottoWinningBonusBallResult.java b/src/main/java/domain/lottowinningresult/LottoWinningBonusBallResult.java new file mode 100644 index 0000000..7ae7ef3 --- /dev/null +++ b/src/main/java/domain/lottowinningresult/LottoWinningBonusBallResult.java @@ -0,0 +1,15 @@ +package domain.lottowinningresult; + +import java.util.List; + +public class LottoWinningBonusBallResult { + private final List LottoWinningBonusBall; + + public LottoWinningBonusBallResult(List LottoWinningBonusBall) { + this.LottoWinningBonusBall = LottoWinningBonusBall; + } + + public List getLottoWinningBonusBallResult(){ + return this.LottoWinningBonusBall; + } +} diff --git a/src/main/java/domain/lottowinningresult/LottoWinningResult.java b/src/main/java/domain/lottowinningresult/LottoWinningResult.java new file mode 100644 index 0000000..4165c08 --- /dev/null +++ b/src/main/java/domain/lottowinningresult/LottoWinningResult.java @@ -0,0 +1,15 @@ +package domain.lottowinningresult; + +import java.util.List; + +public class LottoWinningResult { + private final List lottoWinning; + public LottoWinningResult(List lottoWinning) { + this.lottoWinning = lottoWinning; + } + + public List getLottoWinningResult() { + return this.lottoWinning; + + } +} diff --git a/src/main/java/domain/strategy/RandomLottoNumberStrategy.java b/src/main/java/domain/strategy/RandomLottoNumberStrategy.java new file mode 100644 index 0000000..9700e52 --- /dev/null +++ b/src/main/java/domain/strategy/RandomLottoNumberStrategy.java @@ -0,0 +1,33 @@ +package domain.strategy; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Random; + +public class RandomLottoNumberStrategy { + private final static int UPPER_BOUND = 45; + private final static int LOWER_BOUND = 1; + private final static int LOTTO_NUMBER_COUNT = 6; + + public List getRandomLottoNumbers(){ + List lottoNumberRange = setLottoNumberRange(); + return getLottoNumbers(lottoNumberRange); + } + + private List setLottoNumberRange(){ + ArrayList lottoNumberIndex = new ArrayList<>(); + for (int lottoNumber = LOWER_BOUND; lottoNumber < UPPER_BOUND; lottoNumber++) { + lottoNumberIndex.add(lottoNumber); + } + return lottoNumberIndex; + } + + private List getLottoNumbers(List lottoNumberRange){ + Collections.shuffle(lottoNumberRange); + List collectedNumbers = lottoNumberRange.subList(0,LOTTO_NUMBER_COUNT); + Collections.sort(collectedNumbers); + return collectedNumbers; + } + +} \ No newline at end of file diff --git a/src/main/java/ui/Printer.java b/src/main/java/ui/Printer.java new file mode 100644 index 0000000..bbd09fb --- /dev/null +++ b/src/main/java/ui/Printer.java @@ -0,0 +1,42 @@ +package ui; + +import domain.WinningStatus; +import domain.lottoticket.LottoTicket; +import domain.lottoticket.Lottos; + +import java.util.*; + +public class Printer { + private static final String REQUEST_PURCHASE_AMOUNT_MESSAGE = "구입금액을 입력해 주세요."; + private static final String REQUEST_LAST_WEEK_LOTTO_WINNING_NUMBER_MESSAGE = "지난 주 당첨 번호를 입력해 주세요."; + private static final String REQUEST_LOTTO_BONUS_BALL_NUMBER_MESSAGE = "보너스 볼을 입력해주세요"; + private static final String PRINT_FINAL_MATCHED_LOTTO_RESULT_MESSAGE = "%s개 일치 (%s원)- %s개"; + private static final String PRINT_LOTTO_PROFIT_MESSAGE = "총 수익률은 %f입니다."; + public void requestPurchaseAmount() { + System.out.println(REQUEST_PURCHASE_AMOUNT_MESSAGE); + } + public void requestLastWeekLottoWinningNumber() { + System.out.println(REQUEST_LAST_WEEK_LOTTO_WINNING_NUMBER_MESSAGE); + } + public void requestLottoBonusBallNumber() { + System.out.println(REQUEST_LOTTO_BONUS_BALL_NUMBER_MESSAGE); + } + public void printAllLotto(Lottos lottos){ + for (LottoTicket lotto : lottos.getLottos()) { + System.out.println(lotto.getLotto()); + } + } + + public void printAllMatchedLottoResult(Map lottoPrices) { + List keySet = new ArrayList(lottoPrices.keySet()); + keySet.sort(Comparator.comparingInt(WinningStatus::getWinningMoney)); + + for(WinningStatus key: keySet) { + System.out.println(String.format(PRINT_FINAL_MATCHED_LOTTO_RESULT_MESSAGE, key.getMatchCount(), key.getWinningMoney(), lottoPrices.get(key))); + } + } + + public void printLottoProfit(float calculatedProfit) { + System.out.println(String.format(PRINT_LOTTO_PROFIT_MESSAGE, calculatedProfit)); + } +} \ No newline at end of file diff --git a/src/main/java/ui/Receiver.java b/src/main/java/ui/Receiver.java new file mode 100644 index 0000000..04a600c --- /dev/null +++ b/src/main/java/ui/Receiver.java @@ -0,0 +1,36 @@ +package ui; + +import java.util.Arrays; +import java.util.List; +import java.util.Scanner; +import java.util.stream.Collectors; + +public class Receiver { + private static final Scanner scanner = new Scanner(System.in); + private static final String DELIMITER = ","; + + public int receiveLottoTotalAmount() { + int lottoTotalAmount = scanner.nextInt(); + return lottoTotalAmount; + } + + public int receiveLottoBonusBallNumber() { + int lottoBonusBallNumber = scanner.nextInt(); + return lottoBonusBallNumber; + } + + public List receiveLastWeekLottoWinningNumbers() { + String lastWeekLottoWinningNumbers = scanner.next(); + List dividedLastWeekLottoWinningNumbers = splitInputLine(lastWeekLottoWinningNumbers); + return convertStringToInt(dividedLastWeekLottoWinningNumbers); + } + + private List splitInputLine(String line) { + return Arrays.asList(line.split(DELIMITER)); + } + + private List convertStringToInt(List dividedLastWeekLottoWinningNumbers) { + return dividedLastWeekLottoWinningNumbers.stream().map(Integer::parseInt).collect(Collectors.toList()); + + } +} From c55fa2ba0035a85ae12bb397bfb9ab28cd2767f3 Mon Sep 17 00:00:00 2001 From: ichangyu Date: Thu, 8 Apr 2021 23:57:39 +0900 Subject: [PATCH 2/8] =?UTF-8?q?refactor:=201=EC=B0=A8=20=EB=AF=B8=EC=85=98?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/LottoApplication.java | 8 ++- src/main/java/domain/EnumWinningStatus.java | 6 +- src/main/java/domain/LottoMachine.java | 2 +- src/main/java/domain/Profit.java | 27 ++++++-- .../java/domain/lottoticket/LottoTicket.java | 2 +- .../strategy/RandomLottoNumberStrategy.java | 6 +- src/main/java/ui/Printer.java | 64 +++++++++++++++++-- src/main/java/ui/Receiver.java | 1 - 8 files changed, 92 insertions(+), 24 deletions(-) diff --git a/src/main/java/LottoApplication.java b/src/main/java/LottoApplication.java index fdfe006..9ef73eb 100644 --- a/src/main/java/LottoApplication.java +++ b/src/main/java/LottoApplication.java @@ -24,14 +24,18 @@ public void run() { NumberOfLottoTicket numberOfLottoTicket = new NumberOfLottoTicket(receiver.receiveLottoTotalAmount()); Lottos lottos = makeLottos(numberOfLottoTicket); printer.printAllLotto(lottos); + printer.requestLastWeekLottoWinningNumber(); List LastWeekLottoWinningNumbers = receiver.receiveLastWeekLottoWinningNumbers(); LastWeekWinningLotto lastWeekWinningLotto = new LastWeekWinningLotto(LastWeekLottoWinningNumbers); + printer.requestLottoBonusBallNumber(); LastWeekWinningBonusBall lastWeekWinningBonusBall = new LastWeekWinningBonusBall(receiver.receiveLottoBonusBallNumber()); ArrayList getLottoPrices = lottoMachine.Discriminator(lottos, lastWeekWinningLotto, lastWeekWinningBonusBall, numberOfLottoTicket); - Profit profit = new Profit(getLottoPrices); - printer.printLottoProfit(profit.getCalculatedProfit(numberOfLottoTicket)); + Profit profit = new Profit(getLottoPrices, numberOfLottoTicket); + + printer.printLottoProfit(profit.getProfit()); + printer.printIsLottoProfit(profit.isProfit()); } private Lottos makeLottos(NumberOfLottoTicket numberOfLottoTicket) { diff --git a/src/main/java/domain/EnumWinningStatus.java b/src/main/java/domain/EnumWinningStatus.java index 671fe6e..1b4829c 100644 --- a/src/main/java/domain/EnumWinningStatus.java +++ b/src/main/java/domain/EnumWinningStatus.java @@ -24,7 +24,8 @@ public ArrayList getLottoPrices(LottoFactory lottoFactory, Number Boolean lottoBonusBallNumber = lottoWinningBonusBallResult.getLottoWinningBonusBallResult().get(i); getWinningLottoTicketPrices(lottoMatchedNumber, lottoBonusBallNumber); } - printer.printAllMatchedLottoResult(getMappingLottoWithBonusBall()); + printer.printWinningStatistics(); + printer.printAllMatchedLottoResults(getMappingLottoWithBonusBall()); return lottoPrices; } @@ -49,8 +50,7 @@ private void makeWinningLottoTicket( } private Map getMappingLottoWithBonusBall() { - for (WinningStatus key: lottoPrices - ) { + for (WinningStatus key: lottoPrices) { mappingLottoWithBonusBall.put(key, mappingLottoWithBonusBall.getOrDefault(key, 0)+1); } return mappingLottoWithBonusBall; diff --git a/src/main/java/domain/LottoMachine.java b/src/main/java/domain/LottoMachine.java index bcce726..2212969 100644 --- a/src/main/java/domain/LottoMachine.java +++ b/src/main/java/domain/LottoMachine.java @@ -43,7 +43,7 @@ private LottoFactory createLottoFactory(ArrayList lottoWinningResults, } private int getMatchLottoNumberCount(List lottoMatchedResult){ - return (int) lottoMatchedResult.stream().filter(index-> (index)).count(); + return (int)lottoMatchedResult.stream().filter(index-> (index)).count(); } private List getMatchLottoNumber(LottoTicket lotto, LastWeekWinningLotto lastWeekWinningLotto){ diff --git a/src/main/java/domain/Profit.java b/src/main/java/domain/Profit.java index dcf305b..a983e81 100644 --- a/src/main/java/domain/Profit.java +++ b/src/main/java/domain/Profit.java @@ -5,17 +5,32 @@ import java.util.List; public class Profit { - private static int totalLottoPrice; - public Profit(List lottoPrices) { - int sumLottoPrices = sumLottoPrices(lottoPrices); - totalLottoPrice = sumLottoPrices; + private static final int PROFIT_THRESHOLD = 1; + private static int sumLottoPrices; + private static NumberOfLottoTicket numberOfLottoTicket; + private static float calculatedProfit; + public Profit(List lottoPrices, NumberOfLottoTicket numberOfLottoTicket) { + this.sumLottoPrices = sumLottoPrices(lottoPrices); + this.numberOfLottoTicket = numberOfLottoTicket; + this.calculatedProfit = CalculatedProfit(); } private int sumLottoPrices(List lottoPrices){ return lottoPrices.stream().mapToInt(WinningStatus::getWinningMoney).sum(); } - public float getCalculatedProfit(NumberOfLottoTicket numberOfLottoTicket) { - return (float) totalLottoPrice / numberOfLottoTicket.getMoney(); + private float CalculatedProfit() { + return (float)sumLottoPrices / numberOfLottoTicket.getMoney(); + } + + public boolean isProfit() { + if (calculatedProfit numbers; - public LottoTicket(List numbers ) { + public LottoTicket(List numbers) { checkLottoLength(numbers); this.numbers = numbers; } diff --git a/src/main/java/domain/strategy/RandomLottoNumberStrategy.java b/src/main/java/domain/strategy/RandomLottoNumberStrategy.java index 9700e52..e4462d1 100644 --- a/src/main/java/domain/strategy/RandomLottoNumberStrategy.java +++ b/src/main/java/domain/strategy/RandomLottoNumberStrategy.java @@ -10,12 +10,12 @@ public class RandomLottoNumberStrategy { private final static int LOWER_BOUND = 1; private final static int LOTTO_NUMBER_COUNT = 6; - public List getRandomLottoNumbers(){ + public List getRandomLottoNumbers() { List lottoNumberRange = setLottoNumberRange(); return getLottoNumbers(lottoNumberRange); } - private List setLottoNumberRange(){ + private List setLottoNumberRange() { ArrayList lottoNumberIndex = new ArrayList<>(); for (int lottoNumber = LOWER_BOUND; lottoNumber < UPPER_BOUND; lottoNumber++) { lottoNumberIndex.add(lottoNumber); @@ -23,7 +23,7 @@ private List setLottoNumberRange(){ return lottoNumberIndex; } - private List getLottoNumbers(List lottoNumberRange){ + private List getLottoNumbers(List lottoNumberRange) { Collections.shuffle(lottoNumberRange); List collectedNumbers = lottoNumberRange.subList(0,LOTTO_NUMBER_COUNT); Collections.sort(collectedNumbers); diff --git a/src/main/java/ui/Printer.java b/src/main/java/ui/Printer.java index bbd09fb..45b8253 100644 --- a/src/main/java/ui/Printer.java +++ b/src/main/java/ui/Printer.java @@ -10,33 +10,83 @@ public class Printer { private static final String REQUEST_PURCHASE_AMOUNT_MESSAGE = "구입금액을 입력해 주세요."; private static final String REQUEST_LAST_WEEK_LOTTO_WINNING_NUMBER_MESSAGE = "지난 주 당첨 번호를 입력해 주세요."; private static final String REQUEST_LOTTO_BONUS_BALL_NUMBER_MESSAGE = "보너스 볼을 입력해주세요"; - private static final String PRINT_FINAL_MATCHED_LOTTO_RESULT_MESSAGE = "%s개 일치 (%s원)- %s개"; - private static final String PRINT_LOTTO_PROFIT_MESSAGE = "총 수익률은 %f입니다."; + private static final String PRINT_FINAL_MATCHED_LOTTO_RESULT_MESSAGE = "%s개 일치%s(%s원)- "; + private static final String PRINT_LOTTO_PROFIT_MESSAGE = "총 수익률은 %.2f입니다."; + private static final String PRINT_MATCH_BONUS_BALL_MESSAGE = ", 보너스 볼 일치"; + private static final String PRINT_DIVIDER_MESSAGE = "---------\n"; + private static final String PRINT_WINNING_STATISTICS_MESSAGE = "\n당첨 통계\n"; + private static final String PRINT_PROFIT_LOSS_MESSAGE = "(기준이 1이기 때문에 결과적으로 손해라는 의미임)"; + public void requestPurchaseAmount() { System.out.println(REQUEST_PURCHASE_AMOUNT_MESSAGE); } + public void requestLastWeekLottoWinningNumber() { System.out.println(REQUEST_LAST_WEEK_LOTTO_WINNING_NUMBER_MESSAGE); } + public void requestLottoBonusBallNumber() { System.out.println(REQUEST_LOTTO_BONUS_BALL_NUMBER_MESSAGE); } - public void printAllLotto(Lottos lottos){ + + public void printWinningStatistics() { + System.out.print(PRINT_WINNING_STATISTICS_MESSAGE); + System.out.print(PRINT_DIVIDER_MESSAGE); + } + + public void printAllLotto(Lottos lottos) { for (LottoTicket lotto : lottos.getLottos()) { System.out.println(lotto.getLotto()); } } - public void printAllMatchedLottoResult(Map lottoPrices) { + public void printAllMatchedLottoResults(Map lottoPrices) { List keySet = new ArrayList(lottoPrices.keySet()); keySet.sort(Comparator.comparingInt(WinningStatus::getWinningMoney)); - for(WinningStatus key: keySet) { - System.out.println(String.format(PRINT_FINAL_MATCHED_LOTTO_RESULT_MESSAGE, key.getMatchCount(), key.getWinningMoney(), lottoPrices.get(key))); + for(WinningStatus winningStatus: WinningStatus.values()){ + printMatchedLottoWithBonusBallFormat(winningStatus); + printMatchedLottoFormat(winningStatus); + printMatchedLottoResult(winningStatus, lottoPrices); + } + } + + private void printMatchedLottoResult(WinningStatus winningStatus, Map lottoPrices) { + if (lottoPrices.get(winningStatus) == null){ + System.out.println("0개"); + } + if (lottoPrices.get(winningStatus) != null){ + System.out.println(lottoPrices.get(winningStatus)+"개"); + } + } + + private void printMatchedLottoFormat(WinningStatus winningStatus) { + if (!winningStatus.hasBonusBall()) { + System.out.print(String.format( + PRINT_FINAL_MATCHED_LOTTO_RESULT_MESSAGE, + winningStatus.getMatchCount(), + "", + winningStatus.getWinningMoney())); + } + } + + private void printMatchedLottoWithBonusBallFormat(WinningStatus winningStatus) { + if (winningStatus.hasBonusBall()){ + System.out.print(String.format( + PRINT_FINAL_MATCHED_LOTTO_RESULT_MESSAGE, + winningStatus.getMatchCount(), + PRINT_MATCH_BONUS_BALL_MESSAGE, + winningStatus.getWinningMoney())); } } public void printLottoProfit(float calculatedProfit) { - System.out.println(String.format(PRINT_LOTTO_PROFIT_MESSAGE, calculatedProfit)); + System.out.print(String.format(PRINT_LOTTO_PROFIT_MESSAGE, calculatedProfit)); + } + + public void printIsLottoProfit(boolean isProfit) { + if(!isProfit) { + System.out.println(PRINT_PROFIT_LOSS_MESSAGE); + } } } \ No newline at end of file diff --git a/src/main/java/ui/Receiver.java b/src/main/java/ui/Receiver.java index 04a600c..a87c0ea 100644 --- a/src/main/java/ui/Receiver.java +++ b/src/main/java/ui/Receiver.java @@ -31,6 +31,5 @@ private List splitInputLine(String line) { private List convertStringToInt(List dividedLastWeekLottoWinningNumbers) { return dividedLastWeekLottoWinningNumbers.stream().map(Integer::parseInt).collect(Collectors.toList()); - } } From 37f86afb351d376746863457431b1e551c315b29 Mon Sep 17 00:00:00 2001 From: ichangyu Date: Fri, 9 Apr 2021 00:14:02 +0900 Subject: [PATCH 3/8] =?UTF-8?q?refactor:=20exception=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/exception/NotValidLottoLengthException.java | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 src/main/java/domain/exception/NotValidLottoLengthException.java diff --git a/src/main/java/domain/exception/NotValidLottoLengthException.java b/src/main/java/domain/exception/NotValidLottoLengthException.java deleted file mode 100644 index 19e90ac..0000000 --- a/src/main/java/domain/exception/NotValidLottoLengthException.java +++ /dev/null @@ -1,9 +0,0 @@ -package domain.exception; - -public class NotValidLottoLengthException extends RuntimeException { - private static final String MESSAGE = "번호는 6개를 입력해야 합니다."; - - public NotValidLottoLengthException() { - super(MESSAGE); - } -} \ No newline at end of file From 41e90a8f0d6c9e0cc71195b421541b37b31cfe39 Mon Sep 17 00:00:00 2001 From: ichangyu Date: Fri, 9 Apr 2021 00:34:09 +0900 Subject: [PATCH 4/8] chore: empty branch to start over --- src/main/java/LottoApplication.java | 55 ----------- src/main/java/domain/EnumWinningStatus.java | 59 ------------ src/main/java/domain/LottoFactory.java | 23 ----- src/main/java/domain/LottoMachine.java | 68 -------------- src/main/java/domain/Profit.java | 36 -------- src/main/java/domain/WinningStatus.java | 31 ------- .../LastWeekWinningBonusBall.java | 13 --- .../LastWeekWinningLotto.java | 18 ---- src/main/java/domain/lottoticket/Lotto.java | 7 -- .../java/domain/lottoticket/LottoTicket.java | 25 ----- src/main/java/domain/lottoticket/Lottos.java | 15 --- .../lottoticket/NumberOfLottoTicket.java | 25 ----- .../LottoWinningBonusBallResult.java | 15 --- .../LottoWinningResult.java | 15 --- .../strategy/RandomLottoNumberStrategy.java | 33 ------- src/main/java/{domain => }/empty.txt | 0 src/main/java/ui/Printer.java | 92 ------------------- src/main/java/ui/Receiver.java | 35 ------- 18 files changed, 565 deletions(-) delete mode 100644 src/main/java/LottoApplication.java delete mode 100644 src/main/java/domain/EnumWinningStatus.java delete mode 100644 src/main/java/domain/LottoFactory.java delete mode 100644 src/main/java/domain/LottoMachine.java delete mode 100644 src/main/java/domain/Profit.java delete mode 100644 src/main/java/domain/WinningStatus.java delete mode 100644 src/main/java/domain/lastweekwinninglotto/LastWeekWinningBonusBall.java delete mode 100644 src/main/java/domain/lastweekwinninglotto/LastWeekWinningLotto.java delete mode 100644 src/main/java/domain/lottoticket/Lotto.java delete mode 100644 src/main/java/domain/lottoticket/LottoTicket.java delete mode 100644 src/main/java/domain/lottoticket/Lottos.java delete mode 100644 src/main/java/domain/lottoticket/NumberOfLottoTicket.java delete mode 100644 src/main/java/domain/lottowinningresult/LottoWinningBonusBallResult.java delete mode 100644 src/main/java/domain/lottowinningresult/LottoWinningResult.java delete mode 100644 src/main/java/domain/strategy/RandomLottoNumberStrategy.java rename src/main/java/{domain => }/empty.txt (100%) delete mode 100644 src/main/java/ui/Printer.java delete mode 100644 src/main/java/ui/Receiver.java diff --git a/src/main/java/LottoApplication.java b/src/main/java/LottoApplication.java deleted file mode 100644 index 9ef73eb..0000000 --- a/src/main/java/LottoApplication.java +++ /dev/null @@ -1,55 +0,0 @@ -import domain.LottoMachine; -import domain.Profit; -import domain.WinningStatus; -import domain.lastweekwinninglotto.LastWeekWinningBonusBall; -import domain.lastweekwinninglotto.LastWeekWinningLotto; -import domain.lottoticket.LottoTicket; -import domain.lottoticket.Lottos; -import domain.lottoticket.NumberOfLottoTicket; -import domain.strategy.RandomLottoNumberStrategy; -import ui.Printer; -import ui.Receiver; - -import java.util.ArrayList; -import java.util.List; - -public class LottoApplication { - private final Printer printer = new Printer(); - private final Receiver receiver = new Receiver(); - private static LottoMachine lottoMachine = new LottoMachine(); - private final RandomLottoNumberStrategy randomLottoNumberStrategy = new RandomLottoNumberStrategy(); - - public void run() { - printer.requestPurchaseAmount(); - NumberOfLottoTicket numberOfLottoTicket = new NumberOfLottoTicket(receiver.receiveLottoTotalAmount()); - Lottos lottos = makeLottos(numberOfLottoTicket); - printer.printAllLotto(lottos); - - printer.requestLastWeekLottoWinningNumber(); - List LastWeekLottoWinningNumbers = receiver.receiveLastWeekLottoWinningNumbers(); - LastWeekWinningLotto lastWeekWinningLotto = new LastWeekWinningLotto(LastWeekLottoWinningNumbers); - - printer.requestLottoBonusBallNumber(); - LastWeekWinningBonusBall lastWeekWinningBonusBall = new LastWeekWinningBonusBall(receiver.receiveLottoBonusBallNumber()); - ArrayList getLottoPrices = lottoMachine.Discriminator(lottos, lastWeekWinningLotto, lastWeekWinningBonusBall, numberOfLottoTicket); - Profit profit = new Profit(getLottoPrices, numberOfLottoTicket); - - printer.printLottoProfit(profit.getProfit()); - printer.printIsLottoProfit(profit.isProfit()); - } - - private Lottos makeLottos(NumberOfLottoTicket numberOfLottoTicket) { - ArrayList lottoDummy = new ArrayList<>(); - for (int i = 0; i < numberOfLottoTicket.getNumberOfLottoTicket(); i++) { - LottoTicket lotto = new LottoTicket(randomLottoNumberStrategy.getRandomLottoNumbers()); - lottoDummy.add(lotto); - } - Lottos lottos = new Lottos(lottoDummy); - return lottos; - } - - public static void main(String[] args) { - LottoApplication app = new LottoApplication(); - app.run(); - } -} \ No newline at end of file diff --git a/src/main/java/domain/EnumWinningStatus.java b/src/main/java/domain/EnumWinningStatus.java deleted file mode 100644 index 1b4829c..0000000 --- a/src/main/java/domain/EnumWinningStatus.java +++ /dev/null @@ -1,59 +0,0 @@ -package domain; - -import domain.lottoticket.NumberOfLottoTicket; -import domain.lottowinningresult.LottoWinningBonusBallResult; -import domain.lottowinningresult.LottoWinningResult; -import ui.Printer; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -public class EnumWinningStatus { - private static final int NOT_MATCH_LOTTO = 0; - private ArrayList lottoPrices = new ArrayList<>(); - private Map mappingLottoWithBonusBall = new HashMap<>(); - private Printer printer = new Printer(); - - public ArrayList getLottoPrices(LottoFactory lottoFactory, NumberOfLottoTicket numberOfLottoTicket){ - LottoWinningResult lottoWinningResults = lottoFactory.getLottoWinningResult(); - LottoWinningBonusBallResult lottoWinningBonusBallResult = lottoFactory.getLottoWinningBonusBallResult(); - - for (int i = 0; i < numberOfLottoTicket.getNumberOfLottoTicket(); i++) { - int lottoMatchedNumber = lottoWinningResults.getLottoWinningResult().get(i); - Boolean lottoBonusBallNumber = lottoWinningBonusBallResult.getLottoWinningBonusBallResult().get(i); - getWinningLottoTicketPrices(lottoMatchedNumber, lottoBonusBallNumber); - } - printer.printWinningStatistics(); - printer.printAllMatchedLottoResults(getMappingLottoWithBonusBall()); - return lottoPrices; - } - - private void getWinningLottoTicketPrices(int lottoMatchedNumber, boolean lottoBonusBallNumber) { - for(WinningStatus winningStatus: WinningStatus.values()){ - int matchedWinningNumberCount = winningStatus.getMatchCount(); - boolean isMatchedBonusBallCount = winningStatus.hasBonusBall(); - makeWinningLottoTicket(lottoMatchedNumber, matchedWinningNumberCount, isMatchedBonusBallCount, lottoBonusBallNumber, winningStatus); - } - } - - private void makeWinningLottoTicket( - int lottoMatchedNumber, - int matchedWinningNumberCount, - boolean isMatchedBonusBallCount, - boolean lottoBonusBallNumber, - WinningStatus winningStatus - ){ - if((lottoMatchedNumber == matchedWinningNumberCount) && (isMatchedBonusBallCount == lottoBonusBallNumber)){ - lottoPrices.add(winningStatus); - } - } - - private Map getMappingLottoWithBonusBall() { - for (WinningStatus key: lottoPrices) { - mappingLottoWithBonusBall.put(key, mappingLottoWithBonusBall.getOrDefault(key, 0)+1); - } - return mappingLottoWithBonusBall; - } - -} \ No newline at end of file diff --git a/src/main/java/domain/LottoFactory.java b/src/main/java/domain/LottoFactory.java deleted file mode 100644 index fb17f23..0000000 --- a/src/main/java/domain/LottoFactory.java +++ /dev/null @@ -1,23 +0,0 @@ -package domain; - -import domain.lottowinningresult.LottoWinningBonusBallResult; -import domain.lottowinningresult.LottoWinningResult; - -public class LottoFactory { - private LottoWinningResult lottoWinningResult; - private LottoWinningBonusBallResult lottoWinningBonusBallResult; - - public LottoFactory(LottoWinningResult lottoWinningResults, LottoWinningBonusBallResult lottoWinningBonusBallResults){ - this.lottoWinningResult = lottoWinningResults; - this.lottoWinningBonusBallResult = lottoWinningBonusBallResults; - } - - public LottoWinningResult getLottoWinningResult(){ - return this.lottoWinningResult; - } - - public LottoWinningBonusBallResult getLottoWinningBonusBallResult(){ - return this.lottoWinningBonusBallResult; - } - -} diff --git a/src/main/java/domain/LottoMachine.java b/src/main/java/domain/LottoMachine.java deleted file mode 100644 index 2212969..0000000 --- a/src/main/java/domain/LottoMachine.java +++ /dev/null @@ -1,68 +0,0 @@ -package domain; - -import domain.lastweekwinninglotto.LastWeekWinningBonusBall; -import domain.lastweekwinninglotto.LastWeekWinningLotto; -import domain.lottoticket.LottoTicket; -import domain.lottoticket.Lottos; -import domain.lottoticket.NumberOfLottoTicket; -import domain.lottowinningresult.LottoWinningBonusBallResult; -import domain.lottowinningresult.LottoWinningResult; - -import java.util.ArrayList; -import java.util.List; - -public class LottoMachine { - EnumWinningStatus enumWinningStatus = new EnumWinningStatus(); - ArrayList lottoWinningResults = new ArrayList<>(); - ArrayList lottoWinningBonusBallResults = new ArrayList<>(); - - public ArrayList Discriminator( - Lottos lottos, - LastWeekWinningLotto lastWeekWinningLotto, - LastWeekWinningBonusBall lastWeekWinningBonusBall, - NumberOfLottoTicket numberOfLottoTicket - ){ - for (LottoTicket lotto : lottos.getLottos()) - { - List lottoMatchedResult = getMatchLottoNumber(lotto, lastWeekWinningLotto); - Boolean lottoMatchedBonusBallResult = getMatchLottoBonusBallNumber(lotto, lastWeekWinningBonusBall); - int matchLottoNumberCount = getMatchLottoNumberCount(lottoMatchedResult); - lottoWinningResults.add(matchLottoNumberCount); - lottoWinningBonusBallResults.add(lottoMatchedBonusBallResult); - } - LottoFactory lottoFactory = createLottoFactory(lottoWinningResults, lottoWinningBonusBallResults); - return enumWinningStatus.getLottoPrices(lottoFactory, numberOfLottoTicket); - } - - private LottoFactory createLottoFactory(ArrayList lottoWinningResults, ArrayList lottoWinningBonusBallResults) { - LottoWinningBonusBallResult lottoWinningBonusBallResult = new LottoWinningBonusBallResult(lottoWinningBonusBallResults); - LottoWinningResult winningResult = new LottoWinningResult(lottoWinningResults); - - LottoFactory lottoFactory = new LottoFactory(winningResult, lottoWinningBonusBallResult); - return lottoFactory; - } - - private int getMatchLottoNumberCount(List lottoMatchedResult){ - return (int)lottoMatchedResult.stream().filter(index-> (index)).count(); - } - - private List getMatchLottoNumber(LottoTicket lotto, LastWeekWinningLotto lastWeekWinningLotto){ - List lottoList = lotto.getLotto(); - List lastWeekWinningLottos = lastWeekWinningLotto.getLotto(); - ArrayList lottoMatchedResult = new ArrayList<>(); - - for (int winningLottoNumber = 0; winningLottoNumber < lastWeekWinningLottos.size(); winningLottoNumber++) { - Boolean isMatchLottoNumber = lottoList.contains(lastWeekWinningLottos.get(winningLottoNumber)); - lottoMatchedResult.add(isMatchLottoNumber); - } - return lottoMatchedResult; - } - - private Boolean getMatchLottoBonusBallNumber(LottoTicket lotto, LastWeekWinningBonusBall lastWeekWinningBonusBall) { - List lottoBonusBalls = lotto.getLotto(); - int lastWeekWinningBonusBalls = lastWeekWinningBonusBall.getLastWeekWinningBonusBall(); - Boolean isMatchLottoNumber = lottoBonusBalls.contains(lastWeekWinningBonusBalls); - return isMatchLottoNumber; - - } -} \ No newline at end of file diff --git a/src/main/java/domain/Profit.java b/src/main/java/domain/Profit.java deleted file mode 100644 index a983e81..0000000 --- a/src/main/java/domain/Profit.java +++ /dev/null @@ -1,36 +0,0 @@ -package domain; - -import domain.lottoticket.NumberOfLottoTicket; - -import java.util.List; - -public class Profit { - private static final int PROFIT_THRESHOLD = 1; - private static int sumLottoPrices; - private static NumberOfLottoTicket numberOfLottoTicket; - private static float calculatedProfit; - public Profit(List lottoPrices, NumberOfLottoTicket numberOfLottoTicket) { - this.sumLottoPrices = sumLottoPrices(lottoPrices); - this.numberOfLottoTicket = numberOfLottoTicket; - this.calculatedProfit = CalculatedProfit(); - } - - private int sumLottoPrices(List lottoPrices){ - return lottoPrices.stream().mapToInt(WinningStatus::getWinningMoney).sum(); - } - - private float CalculatedProfit() { - return (float)sumLottoPrices / numberOfLottoTicket.getMoney(); - } - - public boolean isProfit() { - if (calculatedProfit winningLotto; - - public LastWeekWinningLotto(List winningLotto){ - this.winningLotto = winningLotto; - } - - @Override - public List getLotto(){ - return this.winningLotto; - } -} \ No newline at end of file diff --git a/src/main/java/domain/lottoticket/Lotto.java b/src/main/java/domain/lottoticket/Lotto.java deleted file mode 100644 index e6c49a4..0000000 --- a/src/main/java/domain/lottoticket/Lotto.java +++ /dev/null @@ -1,7 +0,0 @@ -package domain.lottoticket; - -import java.util.List; - -public interface Lotto { - public List getLotto(); -} \ No newline at end of file diff --git a/src/main/java/domain/lottoticket/LottoTicket.java b/src/main/java/domain/lottoticket/LottoTicket.java deleted file mode 100644 index bcea143..0000000 --- a/src/main/java/domain/lottoticket/LottoTicket.java +++ /dev/null @@ -1,25 +0,0 @@ -package domain.lottoticket; - -import domain.exception.*; -import java.util.List; - -public class LottoTicket implements Lotto{ - private static final int LOTTO_NUMBER_COUNT = 6; - private final List numbers; - - public LottoTicket(List numbers) { - checkLottoLength(numbers); - this.numbers = numbers; - } - - private void checkLottoLength(List numbers){ - if(numbers.size() !=LOTTO_NUMBER_COUNT){ - throw new NotValidLottoLengthException(); - } - } - @Override - public List getLotto(){ - return this.numbers; - } - -} \ No newline at end of file diff --git a/src/main/java/domain/lottoticket/Lottos.java b/src/main/java/domain/lottoticket/Lottos.java deleted file mode 100644 index 2ce7ded..0000000 --- a/src/main/java/domain/lottoticket/Lottos.java +++ /dev/null @@ -1,15 +0,0 @@ -package domain.lottoticket; - -import java.util.List; - -public class Lottos { - private final List lotto; - - public Lottos(List lotto ) { - this.lotto = lotto; - } - - public List getLottos() { - return this.lotto; - } -} \ No newline at end of file diff --git a/src/main/java/domain/lottoticket/NumberOfLottoTicket.java b/src/main/java/domain/lottoticket/NumberOfLottoTicket.java deleted file mode 100644 index 74f3b4f..0000000 --- a/src/main/java/domain/lottoticket/NumberOfLottoTicket.java +++ /dev/null @@ -1,25 +0,0 @@ -package domain.lottoticket; - -public class NumberOfLottoTicket { - private final static int LOTTO_PRICE = 1000; - private final int tickets; - private final int money; - - public NumberOfLottoTicket(int money) { - this.tickets = setNumberOfLottoTickets(money); - this.money = money; - } - - // naming 바꾸기 - private int setNumberOfLottoTickets(int money) { - return money / LOTTO_PRICE; - } - - public int getNumberOfLottoTicket() { - return this.tickets; - } - - public int getMoney() { - return this.money; - } -} \ No newline at end of file diff --git a/src/main/java/domain/lottowinningresult/LottoWinningBonusBallResult.java b/src/main/java/domain/lottowinningresult/LottoWinningBonusBallResult.java deleted file mode 100644 index 7ae7ef3..0000000 --- a/src/main/java/domain/lottowinningresult/LottoWinningBonusBallResult.java +++ /dev/null @@ -1,15 +0,0 @@ -package domain.lottowinningresult; - -import java.util.List; - -public class LottoWinningBonusBallResult { - private final List LottoWinningBonusBall; - - public LottoWinningBonusBallResult(List LottoWinningBonusBall) { - this.LottoWinningBonusBall = LottoWinningBonusBall; - } - - public List getLottoWinningBonusBallResult(){ - return this.LottoWinningBonusBall; - } -} diff --git a/src/main/java/domain/lottowinningresult/LottoWinningResult.java b/src/main/java/domain/lottowinningresult/LottoWinningResult.java deleted file mode 100644 index 4165c08..0000000 --- a/src/main/java/domain/lottowinningresult/LottoWinningResult.java +++ /dev/null @@ -1,15 +0,0 @@ -package domain.lottowinningresult; - -import java.util.List; - -public class LottoWinningResult { - private final List lottoWinning; - public LottoWinningResult(List lottoWinning) { - this.lottoWinning = lottoWinning; - } - - public List getLottoWinningResult() { - return this.lottoWinning; - - } -} diff --git a/src/main/java/domain/strategy/RandomLottoNumberStrategy.java b/src/main/java/domain/strategy/RandomLottoNumberStrategy.java deleted file mode 100644 index e4462d1..0000000 --- a/src/main/java/domain/strategy/RandomLottoNumberStrategy.java +++ /dev/null @@ -1,33 +0,0 @@ -package domain.strategy; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Random; - -public class RandomLottoNumberStrategy { - private final static int UPPER_BOUND = 45; - private final static int LOWER_BOUND = 1; - private final static int LOTTO_NUMBER_COUNT = 6; - - public List getRandomLottoNumbers() { - List lottoNumberRange = setLottoNumberRange(); - return getLottoNumbers(lottoNumberRange); - } - - private List setLottoNumberRange() { - ArrayList lottoNumberIndex = new ArrayList<>(); - for (int lottoNumber = LOWER_BOUND; lottoNumber < UPPER_BOUND; lottoNumber++) { - lottoNumberIndex.add(lottoNumber); - } - return lottoNumberIndex; - } - - private List getLottoNumbers(List lottoNumberRange) { - Collections.shuffle(lottoNumberRange); - List collectedNumbers = lottoNumberRange.subList(0,LOTTO_NUMBER_COUNT); - Collections.sort(collectedNumbers); - return collectedNumbers; - } - -} \ No newline at end of file diff --git a/src/main/java/domain/empty.txt b/src/main/java/empty.txt similarity index 100% rename from src/main/java/domain/empty.txt rename to src/main/java/empty.txt diff --git a/src/main/java/ui/Printer.java b/src/main/java/ui/Printer.java deleted file mode 100644 index 45b8253..0000000 --- a/src/main/java/ui/Printer.java +++ /dev/null @@ -1,92 +0,0 @@ -package ui; - -import domain.WinningStatus; -import domain.lottoticket.LottoTicket; -import domain.lottoticket.Lottos; - -import java.util.*; - -public class Printer { - private static final String REQUEST_PURCHASE_AMOUNT_MESSAGE = "구입금액을 입력해 주세요."; - private static final String REQUEST_LAST_WEEK_LOTTO_WINNING_NUMBER_MESSAGE = "지난 주 당첨 번호를 입력해 주세요."; - private static final String REQUEST_LOTTO_BONUS_BALL_NUMBER_MESSAGE = "보너스 볼을 입력해주세요"; - private static final String PRINT_FINAL_MATCHED_LOTTO_RESULT_MESSAGE = "%s개 일치%s(%s원)- "; - private static final String PRINT_LOTTO_PROFIT_MESSAGE = "총 수익률은 %.2f입니다."; - private static final String PRINT_MATCH_BONUS_BALL_MESSAGE = ", 보너스 볼 일치"; - private static final String PRINT_DIVIDER_MESSAGE = "---------\n"; - private static final String PRINT_WINNING_STATISTICS_MESSAGE = "\n당첨 통계\n"; - private static final String PRINT_PROFIT_LOSS_MESSAGE = "(기준이 1이기 때문에 결과적으로 손해라는 의미임)"; - - public void requestPurchaseAmount() { - System.out.println(REQUEST_PURCHASE_AMOUNT_MESSAGE); - } - - public void requestLastWeekLottoWinningNumber() { - System.out.println(REQUEST_LAST_WEEK_LOTTO_WINNING_NUMBER_MESSAGE); - } - - public void requestLottoBonusBallNumber() { - System.out.println(REQUEST_LOTTO_BONUS_BALL_NUMBER_MESSAGE); - } - - public void printWinningStatistics() { - System.out.print(PRINT_WINNING_STATISTICS_MESSAGE); - System.out.print(PRINT_DIVIDER_MESSAGE); - } - - public void printAllLotto(Lottos lottos) { - for (LottoTicket lotto : lottos.getLottos()) { - System.out.println(lotto.getLotto()); - } - } - - public void printAllMatchedLottoResults(Map lottoPrices) { - List keySet = new ArrayList(lottoPrices.keySet()); - keySet.sort(Comparator.comparingInt(WinningStatus::getWinningMoney)); - - for(WinningStatus winningStatus: WinningStatus.values()){ - printMatchedLottoWithBonusBallFormat(winningStatus); - printMatchedLottoFormat(winningStatus); - printMatchedLottoResult(winningStatus, lottoPrices); - } - } - - private void printMatchedLottoResult(WinningStatus winningStatus, Map lottoPrices) { - if (lottoPrices.get(winningStatus) == null){ - System.out.println("0개"); - } - if (lottoPrices.get(winningStatus) != null){ - System.out.println(lottoPrices.get(winningStatus)+"개"); - } - } - - private void printMatchedLottoFormat(WinningStatus winningStatus) { - if (!winningStatus.hasBonusBall()) { - System.out.print(String.format( - PRINT_FINAL_MATCHED_LOTTO_RESULT_MESSAGE, - winningStatus.getMatchCount(), - "", - winningStatus.getWinningMoney())); - } - } - - private void printMatchedLottoWithBonusBallFormat(WinningStatus winningStatus) { - if (winningStatus.hasBonusBall()){ - System.out.print(String.format( - PRINT_FINAL_MATCHED_LOTTO_RESULT_MESSAGE, - winningStatus.getMatchCount(), - PRINT_MATCH_BONUS_BALL_MESSAGE, - winningStatus.getWinningMoney())); - } - } - - public void printLottoProfit(float calculatedProfit) { - System.out.print(String.format(PRINT_LOTTO_PROFIT_MESSAGE, calculatedProfit)); - } - - public void printIsLottoProfit(boolean isProfit) { - if(!isProfit) { - System.out.println(PRINT_PROFIT_LOSS_MESSAGE); - } - } -} \ No newline at end of file diff --git a/src/main/java/ui/Receiver.java b/src/main/java/ui/Receiver.java deleted file mode 100644 index a87c0ea..0000000 --- a/src/main/java/ui/Receiver.java +++ /dev/null @@ -1,35 +0,0 @@ -package ui; - -import java.util.Arrays; -import java.util.List; -import java.util.Scanner; -import java.util.stream.Collectors; - -public class Receiver { - private static final Scanner scanner = new Scanner(System.in); - private static final String DELIMITER = ","; - - public int receiveLottoTotalAmount() { - int lottoTotalAmount = scanner.nextInt(); - return lottoTotalAmount; - } - - public int receiveLottoBonusBallNumber() { - int lottoBonusBallNumber = scanner.nextInt(); - return lottoBonusBallNumber; - } - - public List receiveLastWeekLottoWinningNumbers() { - String lastWeekLottoWinningNumbers = scanner.next(); - List dividedLastWeekLottoWinningNumbers = splitInputLine(lastWeekLottoWinningNumbers); - return convertStringToInt(dividedLastWeekLottoWinningNumbers); - } - - private List splitInputLine(String line) { - return Arrays.asList(line.split(DELIMITER)); - } - - private List convertStringToInt(List dividedLastWeekLottoWinningNumbers) { - return dividedLastWeekLottoWinningNumbers.stream().map(Integer::parseInt).collect(Collectors.toList()); - } -} From 6236937bd7472eef57930d809f500a73cd610b6c Mon Sep 17 00:00:00 2001 From: ichangyu Date: Fri, 9 Apr 2021 01:30:25 +0900 Subject: [PATCH 5/8] =?UTF-8?q?docs:=20README=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/README.md b/README.md index 7c9722c..a7d5f58 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,60 @@ 총 수익률은 0.35입니다.(기준이 1이기 때문에 결과적으로 손해라는 의미임) ``` +# 🚀 로또 2단계 - 수동 구매 + +## 기능 요구사항 +- 현재 로또 생성기는 자동 생성 기능만 제공한다. 사용자가 수동으로 추첨 번호를 입력할 수 있도록 해야 한다. +- 입력한 금액, 자동 생성 숫자, 수동 생성 번호를 입력하도록 해야 한다. + +## 프로그래밍 요구사항 +- 예외가 발생하는 부분에 대해 자바 Exception을 적용해 예외처리한다. +- 사용자가 입력한 값에 대한 예외 처리를 철저히 한다. + +### 실행 결과 +``` +구입금액을 입력해 주세요. +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이기 때문에 결과적으로 손해라는 의미임) +``` + ## 프로그래밍 요구사항 - indent(인덴트, 들여쓰기) depth를 2단계에서 1단계로 줄여라. - depth의 경우 if문을 사용하는 경우 1단계의 depth가 증가한다. if문 안에 while문을 사용한다면 depth가 2단계가 된다. @@ -54,3 +108,26 @@ - 로또 자동 생성은 Collections.shuffle() 메소드 활용한다. - Collections.sort() 메소드를 활용해 정렬 가능하다. - ArrayList의 contains() 메소드를 활용하면 어떤 값이 존재하는지 유무를 판단할 수 있다. + +## 구현 할 기능 +- [ ] 구입 금액을 입력 받는다. +- [ ] 수동으로 구매할 수를 입력 받는다. +- [ ] 수동으로 구매할 번호를 입력 받는다. +- [ ] 구입 금액에 따라 수동, 자동으로 각각 몇개씩 구매 했는지 알려준다. +- [ ] 1 - 45 사이의 랜덤한 6개의 숫자 리스트를 구입 개수만큼 만들어 준다. +- [ ] 지난 주 당첨 번호를 입력 받는다. +- [ ] 보너스 볼을 입력 받는다. +- [ ] 일치 여부를 확인 후 당첨 통계를 출력한다. +- [ ] 당첨 금액을 계산한다. +- [ ] 수익률을 계산한다. + +## 예외 목록 +- 구매 금액 + - [ ] 1000원 미만의 금액이 입력될 경우 + +- 로또 번호 + - [ ] 1 - 45 범위의 입력이 아닐 경우 + - [ ] 6개 중 중복된 숫자가 있을 경우 + - [ ] 6개 아닌 수의 입력이 있을 경우 + - [ ] 보너스 볼이 1개가 아닐 경우 + - [ ] 보너스 볼이 6개의 숫자와 중복될 경우 \ No newline at end of file From dd1d112ccf537dc2e00c1cb44fd5bb37e90644cc Mon Sep 17 00:00:00 2001 From: ichangyu Date: Sun, 11 Apr 2021 06:59:35 +0900 Subject: [PATCH 6/8] =?UTF-8?q?feat:=20=EB=A1=9C=EB=98=90=20=EC=88=98?= =?UTF-8?q?=EB=8F=99=20=EB=AF=B8=EC=85=98=20=EC=A0=9C=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 30 ++++---- out/production/classes/LottoApplication.class | Bin 0 -> 2889 bytes out/production/classes/domain/Lotto.class | Bin 0 -> 3933 bytes .../classes/domain/LottoCount.class | Bin 0 -> 1513 bytes .../classes/domain/LottoNumber.class | Bin 0 -> 2576 bytes out/production/classes/domain/LottoRank.class | Bin 0 -> 4731 bytes .../classes/domain/LottoResult.class | Bin 0 -> 2226 bytes out/production/classes/domain/Lottos.class | Bin 0 -> 3276 bytes .../classes/domain/MatchCount.class | Bin 0 -> 1284 bytes out/production/classes/domain/Money.class | Bin 0 -> 1930 bytes .../classes/domain/ProfitResult.class | Bin 0 -> 1188 bytes .../classes/domain/WinningLotto.class | Bin 0 -> 3086 bytes out/production/classes/ui/Printer.class | Bin 0 -> 3369 bytes out/production/classes/ui/Receiver.class | Bin 0 -> 2334 bytes out/test/classes/LottoCountTest.class | Bin 0 -> 821 bytes out/test/classes/LottoRankTest.class | Bin 0 -> 1017 bytes out/test/classes/LottoResultTest.class | Bin 0 -> 1332 bytes out/test/classes/LottoTest.class | Bin 0 -> 1017 bytes out/test/classes/LottosTest.class | Bin 0 -> 255 bytes out/test/classes/MatchCountTest.class | Bin 0 -> 267 bytes out/test/classes/MoneyTest.class | Bin 0 -> 252 bytes out/test/classes/ProfitResultTest.class | Bin 0 -> 273 bytes out/test/classes/WinningLottoTest.class | Bin 0 -> 2083 bytes src/main/java/LottoApplication.java | 54 ++++++++++++++ src/main/java/domain/Lotto.java | 65 +++++++++++++++++ src/main/java/domain/LottoCount.java | 52 +++++++++++++ src/main/java/domain/LottoNumber.java | 69 ++++++++++++++++++ src/main/java/domain/LottoRank.java | 60 +++++++++++++++ src/main/java/domain/LottoResult.java | 25 +++++++ src/main/java/domain/Lottos.java | 49 +++++++++++++ src/main/java/domain/MatchCount.java | 39 ++++++++++ src/main/java/domain/Money.java | 55 ++++++++++++++ src/main/java/domain/ProfitResult.java | 32 ++++++++ src/main/java/domain/WinningLotto.java | 54 ++++++++++++++ src/main/java/ui/Printer.java | 54 ++++++++++++++ src/main/java/ui/Receiver.java | 53 ++++++++++++++ src/test/java/LottoCountTest.java | 12 +++ src/test/java/LottoRankTest.java | 21 ++++++ src/test/java/LottoResultTest.java | 22 ++++++ src/test/java/LottoTest.java | 21 ++++++ src/test/java/WinningLottoTest.java | 20 +++++ 41 files changed, 772 insertions(+), 15 deletions(-) create mode 100644 out/production/classes/LottoApplication.class create mode 100644 out/production/classes/domain/Lotto.class create mode 100644 out/production/classes/domain/LottoCount.class create mode 100644 out/production/classes/domain/LottoNumber.class create mode 100644 out/production/classes/domain/LottoRank.class create mode 100644 out/production/classes/domain/LottoResult.class create mode 100644 out/production/classes/domain/Lottos.class create mode 100644 out/production/classes/domain/MatchCount.class create mode 100644 out/production/classes/domain/Money.class create mode 100644 out/production/classes/domain/ProfitResult.class create mode 100644 out/production/classes/domain/WinningLotto.class create mode 100644 out/production/classes/ui/Printer.class create mode 100644 out/production/classes/ui/Receiver.class create mode 100644 out/test/classes/LottoCountTest.class create mode 100644 out/test/classes/LottoRankTest.class create mode 100644 out/test/classes/LottoResultTest.class create mode 100644 out/test/classes/LottoTest.class create mode 100644 out/test/classes/LottosTest.class create mode 100644 out/test/classes/MatchCountTest.class create mode 100644 out/test/classes/MoneyTest.class create mode 100644 out/test/classes/ProfitResultTest.class create mode 100644 out/test/classes/WinningLottoTest.class create mode 100644 src/main/java/LottoApplication.java create mode 100644 src/main/java/domain/Lotto.java create mode 100644 src/main/java/domain/LottoCount.java create mode 100644 src/main/java/domain/LottoNumber.java create mode 100644 src/main/java/domain/LottoRank.java create mode 100644 src/main/java/domain/LottoResult.java create mode 100644 src/main/java/domain/Lottos.java create mode 100644 src/main/java/domain/MatchCount.java create mode 100644 src/main/java/domain/Money.java create mode 100644 src/main/java/domain/ProfitResult.java create mode 100644 src/main/java/domain/WinningLotto.java create mode 100644 src/main/java/ui/Printer.java create mode 100644 src/main/java/ui/Receiver.java create mode 100644 src/test/java/LottoCountTest.java create mode 100644 src/test/java/LottoRankTest.java create mode 100644 src/test/java/LottoResultTest.java create mode 100644 src/test/java/LottoTest.java create mode 100644 src/test/java/WinningLottoTest.java diff --git a/README.md b/README.md index a7d5f58..6e5ab37 100644 --- a/README.md +++ b/README.md @@ -110,24 +110,24 @@ - ArrayList의 contains() 메소드를 활용하면 어떤 값이 존재하는지 유무를 판단할 수 있다. ## 구현 할 기능 -- [ ] 구입 금액을 입력 받는다. -- [ ] 수동으로 구매할 수를 입력 받는다. -- [ ] 수동으로 구매할 번호를 입력 받는다. -- [ ] 구입 금액에 따라 수동, 자동으로 각각 몇개씩 구매 했는지 알려준다. -- [ ] 1 - 45 사이의 랜덤한 6개의 숫자 리스트를 구입 개수만큼 만들어 준다. -- [ ] 지난 주 당첨 번호를 입력 받는다. -- [ ] 보너스 볼을 입력 받는다. -- [ ] 일치 여부를 확인 후 당첨 통계를 출력한다. -- [ ] 당첨 금액을 계산한다. -- [ ] 수익률을 계산한다. +- [X] 구입 금액을 입력 받는다. +- [X] 수동으로 구매할 수를 입력 받는다. +- [X] 수동으로 구매할 번호를 입력 받는다. +- [X] 구입 금액에 따라 수동, 자동으로 각각 몇개씩 구매 했는지 알려준다. +- [X] 1 - 45 사이의 랜덤한 6개의 숫자 리스트를 구입 개수만큼 만들어 준다. +- [X] 지난 주 당첨 번호를 입력 받는다. +- [X] 보너스 볼을 입력 받는다. +- [X] 일치 여부를 확인 후 당첨 통계를 출력한다. +- [X] 당첨 금액을 계산한다. +- [X] 수익률을 계산한다. ## 예외 목록 - 구매 금액 - - [ ] 1000원 미만의 금액이 입력될 경우 + - [X] 1000원 미만의 금액이 입력될 경우 - 로또 번호 - - [ ] 1 - 45 범위의 입력이 아닐 경우 - - [ ] 6개 중 중복된 숫자가 있을 경우 - - [ ] 6개 아닌 수의 입력이 있을 경우 - - [ ] 보너스 볼이 1개가 아닐 경우 + - [X] 1 - 45 범위의 입력이 아닐 경우 + - [X] 6개 중 중복된 숫자가 있을 경우 + - [X] 6개 아닌 수의 입력이 있을 경우 + - [X] 보너스 볼이 1개가 아닐 경우 - [ ] 보너스 볼이 6개의 숫자와 중복될 경우 \ No newline at end of file diff --git a/out/production/classes/LottoApplication.class b/out/production/classes/LottoApplication.class new file mode 100644 index 0000000000000000000000000000000000000000..89cf858cb26b7ef849fcfa13df2f2e7e0f2ea86c GIT binary patch literal 2889 zcma)833n4!6#gbnI_-42w}DVv%4)hm6>x!8v@M|31dw8};5JRCWgt!BWCGTGUvL*U z-2Df7j!gcKd0k)4SKrhHMFLjoPDCSG-tbK zthp?AI#T(Jm7TF%N7lh+)VtsmMV88YUVgk#$T}IzbMiR?N0%%ory-s^pSoyWwnnm6 zZgFJVBd5ht<;ijvY1_Ghm}IO%K|`$QS+2)tCSS_&*_oQp3+jk+Hz}KR)UjmcN>*0w z`IHIU<~uEUPIe^a6h*H-D!iD&iB%>3q&!CfVe`2COs~POeb$0wryV*SF*ww3OAA zjC2Jv9AXWdDwtsbb=Qqm1h~;Sm(P`o6IM2>p{tCngnklG#hA{Q+>CwPkp%8mvQUoh zle9E3h#_iL%EiPU+@_%^R3;{p7?7N*$#N5SVaUW39x^eBqb6R&OFCXQ@d{ow@fuz? zaT2FYyn#1OyoI-Qykp{BTs83?-e)?ix=<-P?z+~pc_{7AgxW*I> zQeVYRSbt{Xb6hj=1->-#6|U>}+Qc{b*2H(XrsI2A{6HsxT{xU#{v*#*smqgd7wrra zyQM-&*l0+omf}bB#<~QdG(y9o5c@s;4wEq5NXhu;&(qvX`2oZL8q=5)GTzZL4&pZI$C07O=rO#j-8? z=s7ke1v*t!bjzY>@|-}lhr^>zOV|rmF;w}%ZX)R0A<24&tGDLo$0hj_;c!movsvDx zv|yoOmI3?`^({dOq`@Ebj0a!TA)~R-}sw=q` zyaOsJt$;K{@(UVv1c#}5TU2?Zv$nw5M5P0Cgk$PEmTpqR))x?=rlF2jc?h%yX0V+v z?%n(li15#@z!B04IMzdx&cSh*t2F9319}Emp$)DfGP{bp8;Eim}#ZUq+i4RC-T zFrXxcI|<7GOS=kS|Kh5i(qm-Ylo}+cnI8NV(V-PI4-ef$%L!TST|p}q+73q(GH*W| zlifsY1s&x{=L))nPMtd2APmko(`5op*n&=ew${jiP5uZeG z?ilXJ-ITM|aTtgAkI;G;qZlK;*xyTwD7E9bkGe686GLL>>rYTWBAu9{T+3BjNv!+V z(9PJz(>&d#>*yFJd7bmkzabI9+2Nn56IJ{>_yl&TYj5S1_wl-gXTOgV@RYUBvw>&z zd6t>@JHq4`?HZu{jXs?pbq{bA!GrwsbwS3$FB9%dIMq&%z%fHB78f;lEw*IM&un7I9%ZIR6u-(+is#iBK6g=ZEo`~+TUc;|`o?U}JOik&W&*BZ^)d!K#z z_P5U&|Lwmw-UVBE=Tzv;n2VtW`DV<= za14f6a@ztHV_1SImKVg!vMdYYqS%VNVTr<)M@b%^k2C1SRy>YNF+71U$lDiHd`aw| zRPmI8{>*ePH$6LbX7WU8W;Qu}W-2$EdNi4OB$u9^nw?B#vl9=c6vQ(Z^c8)ipj(S0 zS*L7Ti(?A5C2gzX=$3Oax=8$7EZlCvt%-{?G3RQqpQ*Q zQfXtuz-=+_kfmg@V?{5R^SWc4VD(A6YB_{8>*)FANxkI957`R}?(uyFJ1}^AMp4T} zKtXd^zvx1uK=ouSpyRR4O;qt^6%VNR3Y%gX7bmKY?eA+J*yO%F0A=>^@=HDx&3W5$*kAhIHPBG4-)q?s5#}h^ zxs_f)dtOjY+Qp*nMx(18jjqN9)1+TP7(}vF^rG7g+BGj4j*mv1Xt)#L^3pH9MFLk& z>W(gR)Tkc!*1>iOFZXToa|gp%)~=TG#wk;18FRBZC=oOqz*jYl;vnm&hdixUmN+e< z{hEr)8lJ}2H4Gx5;Tw2{%?-{8+2rnYlS>y0#-d)BC@)rvhUKIl&l@Gjv@HeQqyM`0 z;(J%#>AUsP)9<}<<=@X=zxCQXw=S>Udf_>V^Q?l6;#(@dt>HWPu8QwzID+qM z_yK+>HU~BQ2s0XYVJ$J##bDjbs@95%) z)%OxL1>pf1#@)fWP1*z|FG#pYMrVCTT|@=tWMjAai6*##YQH z*j7d*^E$VhY-ZC`DHTlSwtp-A7Nfku2d}G^V=NkFa=4_ID@Iz*l`R7?fq0M`-dxGJ zr5oqpA2?>M&(GiH%tLxihEZn5KMmB%QgvZL_}dYL#2p@iTdh>*WWmuLNHba;;f?t! z8#4S8GTnFV4P!=0AVV)I*wZjwo>ZTLdp5cD$!eF$ z)hG{l7w?{i9DOG>OZrjs9{UyC8%$=CrJsw7gbya?EjSWhz>V9hetHJ0aNDioj~cGw zx`wy#cEbr}S}XRlF_O`XbMrcn34KA&J9e2^w-)Ow6>F?8W82GBVyLAp%P1!cdZl8p z^1lbW?)&o&oYTC&3Pz>h+c*|rLe~4t2}l|?=6K%+&HsO;7xIJm27&cGCwbXqO~+t+ znjPEAPDUqa>gTLtou5iB7u?n~GB-l5I)8gUHJhI^Ic*QEZ8yt7^##Erh4c3{j_`tQV^K;*7k!=iV@sP9KH) zSili{oC?9n+t`*709LVma%k$nyQ7itXj5lXXXI7%9O!I1bTm4=JGzFp zHMFl|M+l#~+@xH6|DQL}d~SFZ@oRMB<=c%Y-+Sn|7j10eUN-G8e~+?#f?9%hd#O1} zxmYGK#y8M@oPQ56wKm#I>q7kXkn|+Olt?|@2)$20qAHH5cu>W0J{7|KANpy*1Wx$n zJxLM?!uPD9weonf%iEVx-Z?q(nC^?v3!K*9_X^F$5t2&)=ozS7qg zoOH=0843?PU8<%N>|1aO5Ba%F(1s~O>u!&}4mENWk?;g~zaP6uC+TXR=b;v-2h*Gio{XHHM;dzR zNu-wwK8YFrNR^_~c1)lz4~38Tva*uPhdS=5LIeH_4DcF^4kO(vu2p98|IL EKg0dHhyVZp literal 0 HcmV?d00001 diff --git a/out/production/classes/domain/LottoCount.class b/out/production/classes/domain/LottoCount.class new file mode 100644 index 0000000000000000000000000000000000000000..42d05b14131655e425a7a3a1c43720962c360863 GIT binary patch literal 1513 zcmZWoOK%%x6g{73#*<9OcI-T86So8?#g9;zQlKHFO=78%B|EN^hZI;u6K9C0I5Xgk zEA^+aLEQkGELy206{r;}7W}5F>bc{IZN&?JkNe$w?m6d<|9|)Q8vwVlZlY{KVcEhY zKA+_2hAb5mH!URbg@kXJ_|jtTR~Ej;Hwp`l+Gee>)7WpUZ|9xwE;g zplS-KYT%!Qjvwwiot~?)5h16K9lz&v>OmL=)u88x3RY+2lDzBrUU*MIFVu>=+^WH$ ztB|RCzPs5wK5)C+&OwKfTs>$xon5Ev$vqD0VcR=Vn5iEI$ByS$hHX|Aj6yAfoM}5J zjWHHlq4+&HZ-q|lr-t)$3^;Yx*I43fQLUDwA6r^R@AyUl`-6OZFU_O?Qr1_)5yqG+eF(~VWUMF^l z4Rp~jH9w4$ocmY9NBrU@`Q2$)fQ=MyY2FgZP#4wmoD=EXC-_FKTxWT^&x!zqe^=C?F&`OIhp_lS6VGKcY z(D|I^njzb1p0W}6Qon2fo{7N;6|qmS!2%ZJHXGa(aZ;rhFn)!p{|Q|?Wk8FVC!@#N z2-xl?#=v>z7)VU5N&OXE08kUyfk7%dcZV|4VwgeH&r(=jU-IDX($ns%K7FR*cu<1f>@ z<%mRoZYu*fR+xL8G_D|z&zPCu&N;y_)9Nj*now&ZtS}JzfYyu9yzv^7dzz4X1#4?h XY}4iR3R4&L-x|@MALuUa&P*_RQN=l)i#%;Q!3u(3_8*ZPsV9KGC>3}CF2ZlO$X72v+R0~ zZ!_$5UdDwW-p2iR#RtE+2q93)I>IYCN*~aw17|r+7f25 zY-vSnS}Rm^4-ph>A3wLjp3epZc1@mE(^FY>+=a=inXH*9!l?dd_g+;BTPnk@q z8BUZsL(r*Dzf#ed)Rss?1tw-M={ajSdY)ygSK8esL0C2-GOv~A9lc3>LTm~``~Hz! z!PRnfBVNN!!sg8d`rqt>8M9K#>Ei|$wX>l&2AL=k-q-+@YLH`G76{v*_B6yxCG8s5T|og0 zd|p&=2&RHXTv1R0)uXe{!I51CnOAUC!CQD+U{f9LBvpaBR>7-?P)pPu>uOf*?KW}e zOF+KLpM(kO+b-_gx?^<$X(sAnCeRd+GT2FNzY@HJ(RWHZoqN&;H23dc?{#(|jU;CoT?i>lU zL{ybKoX0p((8?4mT#aRmYHw1QhPpVk$Dr1G^wMt|y}v}? zVhP)6wWDFZlh%Es45Yiez>-(%aqf)MvIz4IRmwF8|*X=M^3e%et8OClEg>_`K& z6M*yrlK7j*NjzR|*l}7(bR3K=!57>1BV-1bZ18pp0!q_M&;d%4fx8@QyoT3l#Yu27 z^uK}qIN)N=ksqfLbyIi>zl6I8*OmbZzd<}&L2xG2x&-A{GIsKDLheEbX||ITtL8#r zu4*#A4)V^0w3r|WBKf`|R2U5Z2Pqw79o?*n)}9M6%k7e0DFMD27K zGI8vp7(Il(9iujfJ_o(VVUW&8DfV`3!aKx90!!S67P(!#Kv;%2$^?%h?h+iKhG4lu z-k%Yk@i?M+GRxS!KIue*a3LpPXPkr^bCC{EFcvNl_?(DG=sJ~ o(7uAMnI&|84`~@a+`&%Oopx%cE)7#go5|W4!ecm2HWJ4F1Hz;x_5c6? literal 0 HcmV?d00001 diff --git a/out/production/classes/domain/LottoRank.class b/out/production/classes/domain/LottoRank.class new file mode 100644 index 0000000000000000000000000000000000000000..a5925df344ebd9fe40a0f9933eaa915a5516ee26 GIT binary patch literal 4731 zcmb7H`F|7F5&y0vYvuJ~Yyl=1!f8M@!3M%@N-&NbE66srjKQXjvzFKP!fMx*RuIyr zO%GanU+G;^+NMp9BqauHjzVeal{CHY`$*d#`b+ zH*fXgf3DsDuoeHTMhJNYCvZ|mmyAagY{MxY9%aevd3Xa4k0~^~QNf$=c$6&PUW0ew z3=i*A@GiWY-`*qRy{z@V8r0+cJbZwM4@M#3!>sT`6ajo(!6)#^D1t7=rxmQlSp{qG zB)@$|#<>VSt6&8_7r}NJpJ&liGQPmlrx^Z=Oy}tcb_Ri42YK?P2zCY0@bbev`Emri zgVGDP9_PtdB4`hu-1Y=`@>LnnNT?a;?vKYudO8L=yCp=EV|GR}thS`>ICj5g9dDPQ zboCwTFK8%TiNT_JV`(ySI5E&YvcIqQP-2eZ3?7 z9lZxe;zv5;2L}=~?TM#S9S_9W`!Vf=)@EwfL|e+q8rB4PpVw(yIY+acLCwtT#3rLT z>B&wzZ#fbc6!`WO7n$&=ZRK-fNrE&ip(X%6y%Kg-KuZ+Rd|4PSu8B~a2PK4@NrOVEP8k!H=H#;kyEax-DrMsa#!c$X)D4XW!?kUhJZN^@* zuk&aeHk`@*yvHH}Q8XntmFdk(Ia>O7k2dAyb(fdNqFqIom9c6Kx485%uM9)6L^G9H zgy;>}j%HG>Y2`sGytG@V^GH(K90|c#Go_35d)&%gY-*X&F|DZ_x#?b!@Y|EY-a=Wi zAxk{Vxv6Q|!ll>jtG$G2>JysTk)6nAbjyi9lGdjj!?q}~cLdqY1d0Vw+6^X9UEFQj znQ|6Qn<%K3DLbD{>sD(=HR6&={Gq7(P4cmUlpo>wuA3uL(8ww;`l)uwuMXVMng6}hKz5hxQTD7_!e#vt@4^vaTKpn@onfTzJu?wlN$u} zJ;wRIiWl%=9iF3wAJpMEYrG`mhbn%AAJf`TRQwb_Q}J{BLd6&(jDrGSU227Q+BYhJ ze_cPjio^Y-gnBO*r7~l|uOz4i0aqHY9aOO$J5=oCVHXd(d1%LuLSV%$;tDp&PQt>n zQtBH$rl& z#*X^HJq{kYILEFc-yNjiuHe`B4Y%$JM#Fq{{#FR*)=;}RT#lZj`(+g!W7k^XkLRs4 zpP06TS$)h%YmQE#EG{uF^H0Rb4b#!H63UuQ1rWcFG7N$b=j^Pbk4acs*ntY6lJqtf zoi?5Kv}0#Eg^tZFSiMp4T1%8G}K+i(skz)RbxHSqdv! z@>MXVZy!4wH*@;HWY#_@VY5Hp+c7Ex%-;V%jZU*pc^@0ADq@tXMcfjZyy+NICVh|a zEkXA{S%p&Z@`sPOut_{943SeBj@=a#>6Uh*Fm56^9o-I_IK>bWM@u)-Plov|{* z0lMV<>i@gYb@|G+{!Q_aJ2lfx8FVsb{DVFZ#J-CHEc09*51orw*4ww4wt5?V=qvk{ zaPtJ{N&QnisfCIsby4x8MoOBE*n?Nmr~Y1g4`3ytd?C?$lP3?N;&c>^wVkpDT-qNhrBq>&eH&4R?d|K4Wl07Ub5mWC@mLJy>tf4PCr{ja%*ynF94-j0}9fFMZd)O^Txy4 zBIcmtx(Im&cb7Q1NZWl}A|8^&Uq%(|t7ou$uKn)Y?due7nVvmYJ;zeN!S&yG4sz&e zgn|s@7L-e*)fZBIv4HAf&@M<~2dWU5zfU4`>dGGaYLQpU)HSRaimsf+s=24Pne?fZ zd-^>dn_6NMxg(YJJ}R|d7va8P`KhRa3SAZdZ=lP3=>9;<&?!(vs8zhqL;p9G9RJKB}u#kyInzkryKH-}g*7v#~Ff_Q@v-&4inNKw48AZ``n zws1jAFl&dRn+oF1LcB$0ab3}S^xlGeYveky3r-`J8VXHgLu#mM8m+0J@H953hU95% zO#AR00)1ir$Uy0#>@B%mf+1a e=Pvjbs)4uSZ8+_{eaL(J2tJCBd264->Hh)=J!Xgi literal 0 HcmV?d00001 diff --git a/out/production/classes/domain/LottoResult.class b/out/production/classes/domain/LottoResult.class new file mode 100644 index 0000000000000000000000000000000000000000..1f4adcfcc2000d731a78a0c63db5b6056bf2991d GIT binary patch literal 2226 zcmbVN{ZkuN6g@A2Y}qU%godiL6yt%LuQ zGdiPH`h(-oj(?NmdAkeQ1=?|(%AI_5^aZJ^5Ic zeb2JX8?svw7^z!rM|ytG6u6b#U8=R*ju{?|5xw|-~>@LeOr3wmg`CTVbA)3=+dS6b<$@a6;Duc`s$`fJXd4& z(sD*t#m{Kl^b~(bZ5S`j$Na)Z+&*bLBi1wMzi7)&qa|n0C}Z}9K(UnMQZ-VQHga5= zYQ?Euv-Y~{_nPLKrJ9uwRS-1dx>AvW39M@Pz`%!CGmt}G!$$`0p{ilsz{jZ3X~lKD zzSoo84b$6oTm4)H8+qK%X?T#woPmey5<486$&e3Ib_AvpheK<*9&A>0e1mU;)}1Vft<(7wd?%2V z-L8Fbw_kIewg4}{X+jd%cYG(Py1eBom$hg~eO?&UlYl{ubYwR?F0c|O=2^kwWJR%5 zvZyQ;eJa&po4xA$Bqq)4B5*BA7f2v%=21CulfXI4@wTPyhj+G0)g_3a+-Y36fe~OJ?XS;vp*X;#-CFXWI64)CE>Wmm+t>oIg&&AuT9t@7-T&1`g;(P+6lWK4iC>lQ z`zYbe!Y@c4Vo0F2c!*(vg{Q~>htN{|oD=wwheHsP80I|BKiqL9FJOxJr#T;hnTf#Y zv|Yx_Omze%v`o_?$jKEZS0Kv48W>g}exe~2RGXn0450#tl?+FLL-MZXQ%c1=rGium zPf=G~R8d&OND6;Ke}e227z%wnXd#BScuZXp*YFC%rBMpb&%@-X)6zs6EfV|&*9yv; KJaZFo;nu&g0Xk{` literal 0 HcmV?d00001 diff --git a/out/production/classes/domain/Lottos.class b/out/production/classes/domain/Lottos.class new file mode 100644 index 0000000000000000000000000000000000000000..dc6fbaafe1a55f12f91a8abea4bbe98de3c81ca1 GIT binary patch literal 3276 zcma)8ZF3V<6n<{fX4}n{w&|PDP+lyxNh?7uh^7=v6{)761i|9#HrbY?o86jh!214z z@6Pxi{K8kA5uq^S_}THd_yhcaK6iK9>?Rq8&UEj+=bn4cbDneVx%un<-9G@#;71iB zIH}+{6*0`KIE967B=NlbydY&KRnAT)k;02|c1FRX9AA=>ms7OyY7*yBRB-{X$=O8( zmsGrtWfhn4hSYjfe%?~>wt{yA5|-n-PEDY%a8s3Qw zf7AACq3l$2)6Ny-`TQK!RnOFdQ@34#fyllmq)KAev`u$TU}Cb#UcQZf=AuByf>WmZ z-hycxXX}*}qk2JKu_#FuoRV%`)T^dk2f_~bipf}dBgSfUJRH^D+}J*GtQkm4U=dq> zAQG5Xsv5d$c;VCKOtYP~0Yz*{T*-=V*LBOYBG6g#$s2DXXVza^y1kYwx>eI&^9VoF z?6a+2#Akp%B9k~$el$xBG>qwJv;FolwbadW^SOt|6}8opiyffnb({6KP5z$$ zEe3MJnrOSx#^13}9h_UaYLwi3Na9)KU1)PqEjsmT$vADwo0IfuJ1nti*oSv{TN}9M zt5tndHUPP$D_GG`LRrIZ?9s3nV;T-4r@_Fgh9~eO$qZ9hlc)A;Si=>zlv9r5*4(PT zv1GVcoN}!<0kaQRIjr}=(olh|z|pXQ_Y_n$)IhIwToc&U03@*}xUS)SY%2Ib!-x1t z!^ikU!!vl6UOZLrZup$ANE)JTQUv0Y^4jhW*XDv_StQYP?7Z9?YB+7|$ktf5D^A&5 z^*W7&BXBTm#%q`1+D!gYMo$08U5BRiV3qm=xF3LFW8Y0+%MnLvNIj)Pm>&kH_Zr+@j# z1v1tVTZk6c=F&Eslsv|qRRuo?9BLt{T~GpJ z57xs0{(2gLz$5%|m6BbK^HKheiXqK48y@EguGrT2J-}5R9f)(>oxKf_y@%NH)NRD? zpyL)gv(vYb_?4S+9OO4eRbUsty%<0ro%G{TO7{B(Fpfi9(Ny4A&ZNs2CMeYi#otTs zfO-twm_#Ok@>2jMBT?LjvNWBYx`VDQbjNUMnp4%E-a~SEnkcnjXfOF^S`hq(tM@8YV5I0l)rF^=O*kW6IO zOYIPz;%|3Z6B8aP$;eoc(jG6RGxWcW)ZddSJ<1b3h}}o8f|L;d(!3A;7&o8BaeigN zO+4DG5??f&aAh#frp*lIdjf;IcN6YSHJ%aU_XwA z(T_5uFD9+8~jpM!P^SN)cxf5k$wm4tNl}a;T=NO{-C4PZt zZ0=MuCDE{)>J&q`&PAn`b(@Z02u)j#B@Q#FaU(HDudKUhG7RP|$1FDM3udFt7i@|| z^KOOPbG%{6y&qIX%~~e)`9-(REhkgxAQMldBzWa)fuHk}BUMv$6Bq*V1o;b@=bPLn zkj?QPv9k+HW<^XTzN03%Z~O3%NUErDa?n@f%j8C?4wu|!qhfw#Nx_3%uC(lej$wSt zF!Y{O4f}O`hR+#xb-QKQwpr!&OrzSYn~um`teEG75Snn=i}x#1lQe z^@22?p{^Fg5oXnFFlZO#Et@^VFhb}(MSe!7tSKxz)3!has+@tWIo(t8{|pUG(6#TU zn;XC=bVR@~KsyD4wBLxK&OS(;qF&LNO0i*VqIEOvE>fjJ?^yCF*qC}7;juLYenR9A zsHdXArwBbujy;C+g7T6MyS5W|4SGfqrfyfY6ATd|FHgz9lJ$^m66uc<)M zpfHeThB0jSRb=Q*K?IYJpsmt};!%aX;3f}RZzuTB3_GxsBGST-lr4YWbTV}hL3K6t z4+fG?(3hg;E`ov8)N?2WiM)rNThP?|Py>>sZDK N(T>#*NS=b-ZvdNK3*!I) literal 0 HcmV?d00001 diff --git a/out/production/classes/domain/Money.class b/out/production/classes/domain/Money.class new file mode 100644 index 0000000000000000000000000000000000000000..da4bef64bdfc825c596bc7a78df96b10841f7585 GIT binary patch literal 1930 zcmZvdU2ofD6vzKh;>4-vrj5h8t{o%Y3#4h6us5KzjCCO!fut!*DJ@)7ZtA5Tj$Klx zVs~5snlvsZp-D&-#L&iWdcj-Qit%>E1)pSE!Z$#O^Vm*e$`Zx)bDrn?&N=^c>i+r9 zPrm{8z@^>v15Va2Mcx|u0*DAD^jR6}1;ZEeWuYY zsl6@obfiAX5Ls2%S6zK0Qx(G#p75l*RJI!Rigr=wT1!sNY2G#&gE%eYDIAn>01AWb zmzv>7x3_u2(5k92U9UE3nrY|WuV`zwZkaOnV}Nt=GG4>$3^5PUEuZfeWE3$&z3UR) z5=4|_%;F6Zmt~YO$1u^nz1jTiX5!KIR`cGS=G~tYt<4Yry0w{TZEvEr z?ba6`B#y7NKEIi0efd%I#`WfnJ82Pb%9zJndt~&+k_)kqdU&C6%^QuFuY>JD2qp8* zsPYNQ8tOXrB%U1gHN`Q~6vn!h7aaEL4e zt{a}jVOkNu!85Yb1bXlVN{7Sa!?EDQuMvHK(Bk(9??C*G2M9U=qIBnBM9Ns9T)Xgi z2Ojs}3CD{ml*tH=cu`JK3`QG~6h*m@$hY+D<{ozJgAP)5&)_JI(LTd*JWW?FL5^zU zS;iiqXEF67f`lQH;s5|4-@)I;U8H)6*6FK41I|ZbXrd>ws7@asw z(G%p~i;x&)e!H^TAd+V0B8RNFp`8S literal 0 HcmV?d00001 diff --git a/out/production/classes/domain/ProfitResult.class b/out/production/classes/domain/ProfitResult.class new file mode 100644 index 0000000000000000000000000000000000000000..1d6cea669555d7f4f7144e9d911027ab91c6811d GIT binary patch literal 1188 zcmZWn+fEZv6kVqm+73gZEyzVh6x6mLRYXOLynqBu5z;m!`a*^>)`4Nhv}a8815Eq@ zpZo-3G!ZmD_yK;Dah;iIXf;hv&tCiNwPvrqfB*UU3&0{)G-xQKkVH`(vl`}bOT#=$ z>bR{DyOY3zg6}4d97*-~J*a^M~tmQ$*nqh*13!}T1db3N%*1v1;WY&n)(5h&(+@&ReN2McNny8^LQ z_rMewtXPiu%sbvUTXkdKCX%hV4a43wT9%4KFeYDFZGn*v*-p!SX~|H5tu;*${I zhPiGjH!|Iw&MQS7Io#7Rh#?&rWD~fr;{lcuc&OtM%Ia9wF@cMmS2)dX4jqp%!yWNI z-q+sVKQtShE=}WHvj1-Yi8zslXVcqym!&LtDxil2zL&I;PKDR$-hBvX-|?a2Jz3Op zvaCu|f|24Xms;b7M%hR|bnpSA2-3)^&Uw$O=J_9EE{9>BBaEK&joR$N;&+JR>?tC} zxl=^H5{lpg&nyc-${0ygBu(=-N@OZ1!x+XHk-(P`{!Ix*C_qm`nY~bEy!Z`~GsHfu z@e=)k_}28?8T#HkpII0PrhVcJ#ncz)y2Qpqu@w8cgv+GPu^*ag#Mkz4Hz9xJDWf%)WfouL-(NAz1Gh|avEih7#l0gfpFT4j| W+~?zyT|~){=(_*r2J<)lTmCPfO7S27 literal 0 HcmV?d00001 diff --git a/out/production/classes/domain/WinningLotto.class b/out/production/classes/domain/WinningLotto.class new file mode 100644 index 0000000000000000000000000000000000000000..dbc747df31f8ba9d3b89e4ef94bc00d7a1c89cb9 GIT binary patch literal 3086 zcma)8TXz#x6#gcecG@t#x0C{{5d_;LP_6}=iqgs@ng(ovT2RY09onJkq$U$CUQrP% zcmaJ7T)LLa#aj4?+*-heKKncL#ng9~OU3U@CSj)dz)E{&&Y6Ao_w8@*vuA$!_s%^4 zoA5;dk0TL)f<2WS_KM-f0ID&dU{Jxn3hWP{90!EOPyjDscoBMVPz;9@yeyVqQShpQ zkpSv&SXgKQ)M8ZlNCq$lUDzC1geb-pOa#yZLkvg7%A_zzDVPeNO|Te)sUR&Oymug$ z*f$c}Inui)v4604dptfexV?YJ$WUzGZVrh=EU{}OvA@4}$AEPn2~~Y*Gizz4bwEqybP4Kl!!-FQp0+F^RL95CQ<`CR+H=}hj;76AwpUA~Bs6*+ zCUR4wdWI(DJ%(vm+a#=N_ZUPyGsnE+fCRZOJx1u7xMAvr<$c;{iYxW;bW%$l&@zUY zJBzY4VPqvV6}=6)2opVgOiLMKnx*$m=*h|6BHKZ2N*^+;3CFqs!|(?!Ejih*O*_sj z$8~E!&*oB=gwF&t)^&btCkg-WE`h8g(T!GBh^V* zK3ePz^5k?e&@QiOkH_hNW==+335}VSK2G_!MHNgdc#Yys=PVmvm=wA-XK&`u&E(HrUMrX#Q?U!X6&zP_0w-0xjyF`iiMQAR+-X+vGZuS;lv1J`(_i<|7-Au*iDz_x`P+^oX7ketL$c2Tg zOlaAJeuCUdfWBqZo-`KiZHz*Aw60%p%IpJE!P<9DY!kP+N!ZKW7xKnZNSF8c7feMM zwMlXO`_fZWX;buiMpEb9AMIdgsC5Gg5&6O}vi+ie=wl8axjiO=@{^(6QWs{7UGCm;M*!T#+h9?fR>!G9C!z*qNC219MEJQ(!gI*b(5-GQ7 zP!7ucKQ+XU1cm>AA4{#3l6Xrot)8?4Jg@n0@BAH zn~?)J>Hs!`Bezg?2~~GdK3rchi^`t_oZp74wp})oeG_>%yI>khFbyS`20Jnz*4z7~ zdLnJWMhEW>nG5bc3^33izJ*1JHMgNkxP&FVsgm$Bs=MV-q(z=Z&6WGV-9_#2UDORz zih7zi%%brs_scFFmeS)gei1Dvg;qw`W)lq2rj2RXM7d>wSfbj4&FCVZGHl^*EA@Da z&(+dOH&+DtYWV&^KmlK+J%7=&Pc%V}B2jnfQ^e5~3EhDI7MixT&SCLaOj0P)I*aCR zIou-tZexj$A+_AXQu**4mfgm3KZb;~g$S0i0KgKdWRcXeNb1P8g#vD793q>W3MeJ+ zT{dHp%`Q7KA9t?7GkBIMY9Yt%=%wdkJi=-Vx*3^>ho$y6>iF*9y${dvpN-hb%OUO; zD%C6xGa#9@Fo)K}8XW7F}`(r450^U8M&M4wxyCfg_WW@&G6l4b(bkn?36z*F_=H;svy@3 L+!&`jANv0ToUZ4o literal 0 HcmV?d00001 diff --git a/out/production/classes/ui/Printer.class b/out/production/classes/ui/Printer.class new file mode 100644 index 0000000000000000000000000000000000000000..63aeab21a4fbd478ea636d3ff7850ee14a309d60 GIT binary patch literal 3369 zcmaJ^YgZfB72N}Z5n{jw3^q841u>4mJQ}A?o8UUeAlYh!M3IbZC#^aNfn|h5(Z~&b z#cmy!+If&RPMpM0r^RvFdab&CQ0Ssv{oKFMkNt+^KhV`S-S^H&8aZC&!^}PRvCrP; zoO?$6{l9mJo7WV5-oLA5}I_3{XqQMg*N4;awkS`htMIxbS#6R@1HxiDHc*Ehr zV_pS~fwTHKy+5g^ru)Ojd?GbHprCFjoyr(`${5#^*|>r>6U>Ad9SiyVkrIO2Ts-Ly z2K~Wf(Qsri;t$i0&B->og*=A+4<45sn@m z3zo*xr$bYL zv|*$piP%is;MNvTU@|?cCsO@#ekh$y83V#`RZI*OG(BcrL9K+8M+nkb4w5kelERUK z`Z560sg?^owykU>Ba$9A^w`XZJ}334xS(Kr$1P1NbE5^ zH6tQqS0?7@L7S5x<`D(Wg*|0R)Mw&IU_n$CXx2z1`$>*4E#=W)m@8!9`SPuY3itsL z49US(?0zO_nkhOwpyDSAc9x`$=tk^Je6m2(Q&jwaaYWvl9)r(VNN9gX9xuev;W;f% zI1`z|jB;9mE1b^G$Kt+(s4{KTtfD><01f^4l8T>dxQI8nu~cLVUUKCZujStPFn@hB z_sMm4=VX56W{*3+vSgpzx^q2ubJM-`;CAlT>cjUJ^Oqmwt}N!RtoFH>=u#61O`MI# z3>B9&{0xg4evZo;u3%Bcn;PE2+bZ7Cu!MJ2{6fPo@t%gOcwfT@xJJhIq-*#PA8Gg) z*I9?I+?9>|-Ot<)FFn}0cTvo~tDvU0@TX!~!wP<-;RZfY@oO@&Ly6pJ_zhMSG?bWH z8PqU>pn^U5`^#>|A;0_}ck@Pm`MkTc@4!@kB9>JNZjX53kt~aj*F`Hb2az&$t=Hk#s7)fOh`4sp5|+C)&`7eNgZW ztqM43du;Y@+Fdrgfp)jeZlb;4WM@}(XN6i{skK(uBY5trO_$?-eg-vVEqdRF z!+42ak8rjY75_$+iot(j52ub|$fEO*!bL`7LU_X(8pXSbZ_?W#=rt?YK#PK4uSK$(3w?6-e0NCv)MDU4qJZX!YLu%<@0Re74+p(Q$ni;`^ zjFyk8{8TW(vJ&y^rsjiaz%aa0eXOW0#=XZVp&3CO=a~w8o%=<8&6$@ubA&VXsQ3@s zRRpB;XSmLf5T7FF%akr6<`aycDl*j^=1K literal 0 HcmV?d00001 diff --git a/out/production/classes/ui/Receiver.class b/out/production/classes/ui/Receiver.class new file mode 100644 index 0000000000000000000000000000000000000000..cf401427300575b4f14a60a6987bea4b969ea588 GIT binary patch literal 2334 zcma)8TXR!Y6#jM^deSr{r8i2s7_^j@OCuB!XsM<#U?dmlNn47Sc$yyTf%K%4o-p>! zaq3J*AM`Vv%&~N9YxzIA&hqL$EYprj6Ywfjm`q#7H z{{V0dDL2}1x&gy@L&2La1l$-wumN>=%Z+Uaxo}3VXI*$(LD-E(oOa_KoNJ_S#D%B} zF$Hnye_q;MP%tXcJ{r0(7E%+*Xgn60Oh!Yh8aNvgXo+0bu4?|YX3qFkD{GiDg91&# zj5%*i_V`ob+C4B{^Yu#=n9vf4WBY{YyqEysiAQlTTw^locoMoi_YDzOr zJcubgjo2J&q&71&5vm5w18_Ul`gf0Tg~LMDgBHg8=+~mbkY5CBs|!I zmlPyC7z5jDnwi(N4JbSU{PRMro6Ny&F4Nz7&e7e`1B@ zh`QuXJ{aV`VHO!+Mz^9H=DJRso_-G8&S|jkl7PdIk;{z3=3K7AxUCOe*AAEg1Vg6oz8 z4KfimJ-0b3`dJ|6wt{nW|YThoO}RJ^x!I*hU<LYA*U}DiJ?*8-S z&@Xgz7VEQzWdy^xSdV5_qn%0Y!F~qm!4Za(WR5XRCoky`Wl49SL`&`tqo1UjdE&>b zB-BoCNwtpNcC~HYQR)VG(gepdbSgL|#NPycjYkd~C&cSG!LN^U%|&?EtJfeoS6{?o za_-;sB2Jbsq6VsY9csg!9wpSkCQvS%D)(0pQ<8sMA7k6(GFl#>bp`dZ(fE7HZ#`G= MpBI5at_}?S3v;GdZvX%Q literal 0 HcmV?d00001 diff --git a/out/test/classes/LottoCountTest.class b/out/test/classes/LottoCountTest.class new file mode 100644 index 0000000000000000000000000000000000000000..c9710a4a82f13d24c408805edc300bdfbd993897 GIT binary patch literal 821 zcmZuvU279T6g`vX!>ntXwpvZC*7{MCR@@g~L=i%;5Li?+M0^U9bVw(pJ9T#=_$Jr~ z(FgM&*g_Qreb*|j)Z!2Dr!@N;#5PrEki029sc$iidPmtF%@n)$w#i1o{TUz3_dv_j;rEakIDH4d1QT!WZkkmv3s}hqZ9) zyNSZL-EeI)%Ku;Yd9T*neOBAwdcOZ{ueSeXqxb3)L!x2y87AB%wZf(644YEJ+T zv7^bBcGVx0s9)k zHrZs9OyU@w?S26=7^Miv5;+!;tBBJHnEHv>qwG?4VFx4b!ZzYRkjP%&M)KiMF@q7R jOp}_09I=h^WS>1yw#koSoVraAW+pgJp5X-97$*M$Zg=8L literal 0 HcmV?d00001 diff --git a/out/test/classes/LottoRankTest.class b/out/test/classes/LottoRankTest.class new file mode 100644 index 0000000000000000000000000000000000000000..99957c1ea9bc626add3c7a286da5cb71856a060d GIT binary patch literal 1017 zcma)4T~8B16g^YQE?u@35kEjg@dH~dtRE!CKuk(Q)5aB&b}5FJW?D8dwd~g2sfqHd z^g)RazWL&hGTzzNZ9yK`hdXobnS1X!JM;U`kDmb6ux4Nqw+zf;&cJQVr)YP_zyj{7 z-8~f+Rk*Lh104@_JYvu`geT-{hOum}&X6qn2QEX#7M{D^J8rsx!;}aA>uA zB!FU9NH?%}S6G84M$PX9Ew>~F^G8Okw)sbH!bDofl8I}0tRrh8hh-B_kk_$dVilH& zr^uUlrowX-ULenqKBJalN;R`O+&i>(nr*iwDRtlNroHQ%6`s1pC_+*WrByH z8_2fR@&h;WP>2%BXUPwW9par&U6)K7{iDtir#UaP_W9xKx#+L_*RU_G-A_R#)sq%uXmc zHEf;gJ$bPtw~Y{4-`oES(H2%}|{(e4SQ$i4+sK F`4@}M?FRq= literal 0 HcmV?d00001 diff --git a/out/test/classes/LottoResultTest.class b/out/test/classes/LottoResultTest.class new file mode 100644 index 0000000000000000000000000000000000000000..1ca6fc2b79a6e66a6a1cdc64679b29b2c174dcae GIT binary patch literal 1332 zcmZuxTTj$b5dO|CY@rlU!TViN7g?=$#YJ>MaF-M@P(hzIhqXenv}=26qVYi!A547E z#1~B@(ZnC1c)?rz0sa)(-(Z~6uDUC>$(+vR%zWR>?0*0G`5SY`l@=ZSFkY%;umAEs(eOu~PV}qEn1BO+G;R)f5SwZLs(+WhE zAyavAzq0VISebuUnSWoIzgztA`d)GA<@2Sdk1O*}i%X9l{CNA7jL()HzG6^)?p}`* z$m+BFCf7q@JNgJOQ?`^JBl?pFCX!sGR+dh4%K&1@XtaCcfS zxWbyY{A?d(+%Oip!k)7x?7$|%IoI_B7q;gT-_3^SPwTTGHI8K27M8E`vaMICtK(ki zm#iUM_N}7^sPrF@)HJL{JN4}^%{&igh^m4U8cw1|!6^+{^eQ;5p$}&?oJEg@9C~OH z%R3}?c8!;Z8nzc%TOm#V_Eey@$h0Dc}oH>w} z!~fS$9g5M{HjY8L$(_&|y+#vB7rOq_T87rYq=_)?T{$EGC(|{-F{;|hR4ug`t0snx zLxqXK7-?~`VCIYcqZclX7yEOD!O&vn#|Eoj;!&;gXS3wWx6@viLWc{>q!Bw8efu`e zjeZWpw8e7JJP0gb%<3i2x1u@cB7@w8A>y32lhN6@ZxQTG@<;oE z<}2NcP)9N!(DD&l2Ur6`F%_HCoD?PQVccF@VNlVk$BegT^kTR#8* literal 0 HcmV?d00001 diff --git a/out/test/classes/LottoTest.class b/out/test/classes/LottoTest.class new file mode 100644 index 0000000000000000000000000000000000000000..0ad1cc956c945d67e896e89e91d22ee221895458 GIT binary patch literal 1017 zcmZXST~8B16o%hvp7T0X=UR#u?kM+u2yFeWP|(qO{fw5(;CvO~606MvRB zie7l-l|Rb(&K605P3Fv*GiT2{=bicU_vbGFHEiZkz>I_09Of`@%|izZc|1ZThbk5w zEIIHTJa(|`z|Z1I7ApdoO%*A#C6KOE_XS3_^1Ux&(sB+c4(5dz-ZUT1q#8TK9(x-lQ?t6l8x8WNP%L|k)NgC zH>&FgDk(8}@vtu^{|}tMl)E`tcV*P}_e`v!c72QGr#|!}qmILU)l;N>8AaMiqjW^r z=|IPAztd;ev?t1hu`f@Qe@36%)BU&=?kL-IA>p+<%a+l_IEn;b@ye@SdCe==yz;tN z-pFFr#TsfZCb2FcRfZrdSPrjeoMz; zBGk(yV8z_g@phN{4PFq-8gCjbBd literal 0 HcmV?d00001 diff --git a/out/test/classes/LottosTest.class b/out/test/classes/LottosTest.class new file mode 100644 index 0000000000000000000000000000000000000000..a5f52ac18be4c485430affe23e39c4fcd375bbf8 GIT binary patch literal 255 zcmYL@J!->15QX39HXdmUxXV>Z@ZR)?BqX`&xd?{ zG}`%Q$MWm_{{--ZzK;ev9=aZS1b417rT++x@nlc17x_UFdXdWHy1c})*oio0GKlg- zqCv_$Cqm|IfX_1$i-pQ-}CHULCEE2g?raP?1v$ME~05%*#w;u6ZCJa-N x9m7q0mWjp)7Jt|r;>#^omt9zSz?nWkcLo+bR+q6^ZL$W{?4Sj|Vr^Cn!3WF`Hk|+f literal 0 HcmV?d00001 diff --git a/out/test/classes/MoneyTest.class b/out/test/classes/MoneyTest.class new file mode 100644 index 0000000000000000000000000000000000000000..24bbd213e2af789b77275e5c211317660e05f37b GIT binary patch literal 252 zcmX|*Jqp4=5QX35*TndPH?UI+)7U9Cf>qQ)vERf+S7HJ&3LeW!ulxM7kA) z(*6gn@}SOydbG$hdE3ZyIVSk){8A)xu5_&V-wco9Dgs!r3ErO)+M0){$oAnXKFXv- q7Y2W*i?}(!>aYtd57>hT=+3}^%jz)Jr#04~nr(RSD^_PU5PSi|=P<+o literal 0 HcmV?d00001 diff --git a/out/test/classes/ProfitResultTest.class b/out/test/classes/ProfitResultTest.class new file mode 100644 index 0000000000000000000000000000000000000000..a0fd87a8378635ab77ea3851ef9558da7b457e05 GIT binary patch literal 273 zcmZ9G%?`m(5QWdJ{!pbN@c?#M=*EuNNUQ`w>~HJhO0`LQ>%FWb79PMuiMfrHndD^7 zcV?1#f1WP@BeYyp&~VUn;4|10nMgHdsPy`K26L7k1cSejiC7lbP-HtE#zfkSG~)4| zXHxqgG}T$=I$LMyQL2r|i&*VMuEq@RHZ8J9%%#5W{4WeI{Kh?)uoznZAt4lpe4K53oA{0}iQ8Sg%$|y>hltgIlsXsR8c`MM^oE literal 0 HcmV?d00001 diff --git a/out/test/classes/WinningLottoTest.class b/out/test/classes/WinningLottoTest.class new file mode 100644 index 0000000000000000000000000000000000000000..2007f4fcdecea6c6871dbabd1fb803b65493c403 GIT binary patch literal 2083 zcmb_d-*XdH6#j0SX6a^aOA0MW#ehMRHnRL^D;fmTN+G(XNMjkths-8f(hZxvnau{} zjRzl?!3UkunKDxyePGbH$^%54@egqPOPcsEIG($^kc3vIgp)Fca7w~y2{R0lv!-pj=NJZ( zsa1yX0xug3BbsR&mz%Ys;pFwAMVgq#OS-kHJEo8WW!POa8{+JmY1^h<(YWjKywPwo z3>VvXf9*W{sr~TIU+b-{&D(|cj~ngvuY9>Mx3#&^{{HL2*5tl#O} zYZcl*f77|U(RpyY(0R1c{^35upe5Wg3~Oax(@k6T!cd5)ci_`x*w=ULYYBAlYSVVj znz3p&Ok$q3ZSLx>$!#J&sd1;GR-04-`qoX?a8$i+szC}@EWK7N>xus1{hhh+ijONv(@raUB}IOscP#)cRPj;nOjhNap&1LDgkkLQX~$AJ8qJQMV*$ zMAG9y-WNy{(8<}h;Vf8sqhZhteY%^DdUGZW9Ji{LxMTQZ_B6+=canHM7Nw9D1G>%7 z$BP+WHIs}o$(Bc*~r-q zSGP;XGWGOKZ%@7YQcHKvKkyg?mawGYGCopp2$K@7GR*F1_H3qnyKVLE8+X&b$!{2{ z<~;#)PxR}QGIyw+(OOrMkf%3PGTr} z0xd*h(j)A-*7Z3q^kf?$+bDUSAdiR0r-%{v{RA;07{`A4(L{K-0~F^Vp#-a!fl*nE zW5D4&!n6aTzhUT;sp-d%dqVnY?Day7`!LTj;mP#`4v@oFXdkBaFj07w_8}tk9<4Fj box_JX9~r_jR&a$Vyg_ manualLottoNumbers = getManualLottoNumbers(count); + printer.printNumberOfLottoTickets(count); + Lottos lottos = Lottos.createLottos(manualLottoNumbers, count); + printer.printLottos(lottos); + WinningLotto winningLotto = getWinningLotto(); + ProfitResult result = winningLotto.getResult(lottos); + printer.printLottoProfit(result); + printer.printIsLottoProfit(result.isProfit()); + } + + private List getManualLottoNumbers(LottoCount count) { + List manualLottoNumbers = new ArrayList<>(); + if (count.hasManualLottoCount()) { + manualLottoNumbers.addAll(receiver.receiveManualLottoNumbers(count)); + } + return manualLottoNumbers; + } + + private LottoCount getCountByMoney() { + int inputMoney = receiver.receiveMoney(); + Money money = new Money(inputMoney); + return money.getLottoCount(receiver.receiveManualNumberOfLottoTickets()); + } + + private WinningLotto getWinningLotto() { + Lotto winningLotto = Lotto.of(receiver.receiveWinningLottoNumbers()); + LottoNumber bonusBall = LottoNumber.of(receiver.receiveBonusBall()); + return new WinningLotto(winningLotto, bonusBall); + } +} \ No newline at end of file diff --git a/src/main/java/domain/Lotto.java b/src/main/java/domain/Lotto.java new file mode 100644 index 0000000..07db74e --- /dev/null +++ b/src/main/java/domain/Lotto.java @@ -0,0 +1,65 @@ +package domain; + +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +public class Lotto { + + private static final String LOTTO_NUMBER_COUNT_EXCEPTION_MESSAGE = "6개를 입력해주세요"; + private static final String DELIMITER = ", "; + private static final int NUMBER_COUNT_ZERO = 0; + private static final int NUMBER_COUNT = 6; + + private final Set balls; + + private Lotto(Set balls) { + validateBallCount(balls); + this.balls = Collections.unmodifiableSet(new HashSet<>(balls)); + } + + private void validateBallCount(Set balls) { + if (balls.size() != NUMBER_COUNT) { + throw new IllegalArgumentException(LOTTO_NUMBER_COUNT_EXCEPTION_MESSAGE); + } + } + + public static Lotto of(String rawLotto) { + String[] numbers = rawLotto.split(DELIMITER); + Set balls = new HashSet<>(); + for (String number : numbers) { + balls.add(LottoNumber.of(Integer.parseInt(number))); + } + return new Lotto(balls); + } + + public static Lotto newAutoLotto() { + List balls = LottoNumber.getBalls(); + Collections.shuffle(balls); + Set randomBalls = new HashSet<>(balls.subList(NUMBER_COUNT_ZERO, NUMBER_COUNT)); + return new Lotto(randomBalls); + } + + public static boolean moreThanBallCount(int matchCount) { + return matchCount > NUMBER_COUNT; + } + + public boolean contains(LottoNumber ball) { + return balls.contains(ball); + } + + public int countCommonBalls(Lotto lotto) { + Set sameBalls = new HashSet<>(balls); + sameBalls.retainAll(lotto.balls); + return sameBalls.size(); + } + + public List getLotto() { + List ballsData = balls.stream() + .map(LottoNumber::toString) + .collect(Collectors.toList()); + return Collections.unmodifiableList(ballsData); + } +} \ No newline at end of file diff --git a/src/main/java/domain/LottoCount.java b/src/main/java/domain/LottoCount.java new file mode 100644 index 0000000..e6b5580 --- /dev/null +++ b/src/main/java/domain/LottoCount.java @@ -0,0 +1,52 @@ +package domain; + +import java.util.Objects; + +public class LottoCount { + private static final int MINIMUM_MANUAL_LOTTO_COUNT = 0; + private final int manualLottoCount; + private final int lottoCount; + + public LottoCount(int lottoCount) { + this(lottoCount, MINIMUM_MANUAL_LOTTO_COUNT); + } + + public LottoCount(int lottoCount, int manualLottoCount) { + this.lottoCount = lottoCount; + this.manualLottoCount = manualLottoCount; + } + + public boolean hasManualLottoCount() { + return manualLottoCount != 0; + } + + public Money getBuyMoney(int lottoPrice) { + return new Money(lottoCount * lottoPrice); + } + + public int getAutoLottoCount() { + return lottoCount - manualLottoCount; + } + + public int getManualLottoCount() { + return manualLottoCount; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LottoCount that = (LottoCount) o; + return manualLottoCount == that.manualLottoCount && + lottoCount == that.lottoCount; + } + + @Override + public int hashCode() { + return Objects.hash(manualLottoCount, lottoCount); + } +} \ No newline at end of file diff --git a/src/main/java/domain/LottoNumber.java b/src/main/java/domain/LottoNumber.java new file mode 100644 index 0000000..e77cdde --- /dev/null +++ b/src/main/java/domain/LottoNumber.java @@ -0,0 +1,69 @@ +package domain; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +public class LottoNumber implements Comparable { + + private static final int MINIMUM_LOTTO_NUMBER = 1; + private static final int MAXIMUM_LOTTO_NUMBER = 45; + private static final String PRINT_IF_NUMBER_IS_INVALID_NUMBER = "유효한 로또 번호가 아닙니다."; + private static final Map MAPPING_BALL = new HashMap<>(); + + private final int number; + + static { + DisposeBall(); + } + + private static void DisposeBall() { + for (int ballNumber = MINIMUM_LOTTO_NUMBER; ballNumber <= MAXIMUM_LOTTO_NUMBER; ballNumber++) { + MAPPING_BALL.put(ballNumber, new LottoNumber(ballNumber)); + } + } + + private LottoNumber(int number) { + this.number = number; + } + + public static LottoNumber of(int number) { + if (MAPPING_BALL.containsKey(number)) { + return MAPPING_BALL.get(number); + } + throw new IllegalArgumentException(PRINT_IF_NUMBER_IS_INVALID_NUMBER); + } + + public static List getBalls() { + return new ArrayList<>(MAPPING_BALL.values()); + } + + @Override + public String toString() { + return Integer.toString(number); + } + + @Override + public int compareTo(LottoNumber o) { + return Integer.compare(number, o.number); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LottoNumber ball = (LottoNumber) o; + return number == ball.number; + } + + @Override + public int hashCode() { + return Objects.hash(number); + } +} \ No newline at end of file diff --git a/src/main/java/domain/LottoRank.java b/src/main/java/domain/LottoRank.java new file mode 100644 index 0000000..630c5e0 --- /dev/null +++ b/src/main/java/domain/LottoRank.java @@ -0,0 +1,60 @@ +package domain; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public enum LottoRank { + THREE_MATCH(new MatchCount(3), false, new Money(5_000)), + FOUR_MATCH(new MatchCount(4), false, new Money(50_000)), + FIVE_MATCH(new MatchCount(5), false, new Money(1_500_000)), + FIVE_MATCH_WITH_BONUS_BALL(new MatchCount(5), true, new Money(30_000_000)), + SIX_MATCH(new MatchCount(6), false, new Money(2_000_000_000)); + + private static final String THERE_IS_NON_RANK_EXCEPTION_MESSAGE = "꽝!"; + + private final MatchCount matchCount; + private final boolean bonusMatch; + private final Money money; + + LottoRank(MatchCount matchCount, boolean bonusMatch, Money money) { + this.matchCount = matchCount; + this.bonusMatch = bonusMatch; + this.money = money; + } + + public static LottoRank getRank(int matchCount, boolean bonusMatch) { + List lottoRanks = Arrays.stream(values()) + .filter(lottoRank -> lottoRank.matchCount.getMatchCount() == matchCount) + .sorted() + .collect(Collectors.toList()); + return getRankWithBonus(lottoRanks, bonusMatch); + } + + private static LottoRank getRankWithBonus(List lottoRanks, boolean bonusMatch) { + if (lottoRanks.size() == 1) { + return lottoRanks.get(0); + } + return lottoRanks.stream() + .filter(lottoRank -> lottoRank.bonusMatch == bonusMatch) + .findFirst() + .orElseThrow(() -> new IllegalArgumentException(THERE_IS_NON_RANK_EXCEPTION_MESSAGE)); + } + + public static boolean isMatchedCount(int matchCount) { + return Arrays.stream(values()) + .anyMatch(rank -> rank.matchCount.getMatchCount() == matchCount); + } + + public long getTotal(int count) { + return this.money.multiply(count); + } + + public int getMatchCount() { + return this.matchCount.getMatchCount(); + } + + public int getMoney() { + return this.money.getMoney(); + } +} diff --git a/src/main/java/domain/LottoResult.java b/src/main/java/domain/LottoResult.java new file mode 100644 index 0000000..303e6b1 --- /dev/null +++ b/src/main/java/domain/LottoResult.java @@ -0,0 +1,25 @@ +package domain; + +import java.util.Collections; +import java.util.Map; +import java.util.Set; + +public class LottoResult { + + private final Map rankResult; + + public LottoResult(Map rankResult) { + this.rankResult = Collections.unmodifiableMap(rankResult); + } + + public long calculateTotalPrize() { + Set lottoRanks = rankResult.keySet(); + return lottoRanks.stream() + .mapToLong(lottoRank -> lottoRank.getTotal(rankResult.get(lottoRank))) + .sum(); + } + + public Map getRankResult() { + return rankResult; + } +} diff --git a/src/main/java/domain/Lottos.java b/src/main/java/domain/Lottos.java new file mode 100644 index 0000000..a61f2fc --- /dev/null +++ b/src/main/java/domain/Lottos.java @@ -0,0 +1,49 @@ +package domain; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; + +public class Lottos implements Iterable { + + private final List lottos; + private final LottoCount lottoCount; + + private Lottos(List lottos, LottoCount lottoCount) { + this.lottos = Collections.unmodifiableList(new ArrayList<>(lottos)); + this.lottoCount = lottoCount; + } + + public static Lottos createLottos(List manualLotto, LottoCount count) { + List lottos = new ArrayList<>(); + lottos.addAll(createManualLottos(manualLotto, count)); + lottos.addAll(createRandomLottos(count)); + return new Lottos(lottos, count); + } + + private static List createManualLottos(List manualLotto, LottoCount count) { + return manualLotto.stream() + .map(Lotto::of) + .collect(Collectors.toList()); + } + + private static List createRandomLottos(LottoCount count) { + List lottos = new ArrayList<>(); + int lottoCount = count.getAutoLottoCount(); + for (int i = 0; i < lottoCount; i++) { + lottos.add(Lotto.newAutoLotto()); + } + return lottos; + } + + public LottoCount getCount() { + return lottoCount; + } + + @Override + public Iterator iterator() { + return lottos.iterator(); + } +} \ No newline at end of file diff --git a/src/main/java/domain/MatchCount.java b/src/main/java/domain/MatchCount.java new file mode 100644 index 0000000..0dfec95 --- /dev/null +++ b/src/main/java/domain/MatchCount.java @@ -0,0 +1,39 @@ +package domain; + +import java.util.Objects; + +public class MatchCount { + + private static final int MINIMUM_MATCH_COUNT = 1; + private static final String INVALID_MATCH_COUNT_EXCEPTION_MESSAGE = "유효하지 않는 일치 갯수입니다."; + + private final int matchCount; + + public MatchCount(int matchCount) { + if (matchCount < MINIMUM_MATCH_COUNT || Lotto.moreThanBallCount(matchCount)) { + throw new IllegalArgumentException(INVALID_MATCH_COUNT_EXCEPTION_MESSAGE); + } + this.matchCount = matchCount; + } + + public int getMatchCount() { + return matchCount; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MatchCount that = (MatchCount) o; + return matchCount == that.matchCount; + } + + @Override + public int hashCode() { + return Objects.hash(matchCount); + } +} \ No newline at end of file diff --git a/src/main/java/domain/Money.java b/src/main/java/domain/Money.java new file mode 100644 index 0000000..2afa19b --- /dev/null +++ b/src/main/java/domain/Money.java @@ -0,0 +1,55 @@ +package domain; + +import java.util.Objects; + +public class Money { + + private static final int ONE_LOTTO_PRICE = 1000; + private static final String MONEY_EXCEPTION_MESSAGE = String.format("로또 구매를 위한 최소 금액은 %d원 입니다.", ONE_LOTTO_PRICE); + + private final int money; + + public Money(int money) { + validatePositive(money); + this.money = money; + } + + private void validatePositive(int money) { + if (money < ONE_LOTTO_PRICE) { + throw new IllegalArgumentException(MONEY_EXCEPTION_MESSAGE); + } + } + + public static Money getMoney(LottoCount lottoCount) { + return lottoCount.getBuyMoney(ONE_LOTTO_PRICE); + } + + public LottoCount getLottoCount(int manualLottoCount) { + return new LottoCount(money / ONE_LOTTO_PRICE, manualLottoCount); + } + + public int multiply(int count) { + return money * count; + } + + public int getMoney() { + return money; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Money money1 = (Money) o; + return money == money1.money; + } + + @Override + public int hashCode() { + return Objects.hash(money); + } +} diff --git a/src/main/java/domain/ProfitResult.java b/src/main/java/domain/ProfitResult.java new file mode 100644 index 0000000..3315fa7 --- /dev/null +++ b/src/main/java/domain/ProfitResult.java @@ -0,0 +1,32 @@ +package domain; + +import java.util.Map; + +public class ProfitResult { + private static final int PROFIT_THRESHOLD = 1; + + private final LottoResult lottoResult; + private final LottoCount count; + + public ProfitResult(LottoResult lottoResult, LottoCount count) { + this.lottoResult = lottoResult; + this.count = count; + } + + public float getProfitRate() { + float totalPrize = lottoResult.calculateTotalPrize(); + Money money = Money.getMoney(count); + return totalPrize / money.getMoney(); + } + + public boolean isProfit() { + if (getProfitRate() < PROFIT_THRESHOLD) { + return false; + } + return true; + } + + public Map getLottoResult() { + return lottoResult.getRankResult(); + } +} \ No newline at end of file diff --git a/src/main/java/domain/WinningLotto.java b/src/main/java/domain/WinningLotto.java new file mode 100644 index 0000000..1743059 --- /dev/null +++ b/src/main/java/domain/WinningLotto.java @@ -0,0 +1,54 @@ +package domain; + +import java.util.LinkedHashMap; +import java.util.Map; + +public class WinningLotto { + + private static final String PRINT_IF_BONUSBALL_SAME_WITH_WINNING_NUMBER = "보너스 볼은 당첨 번호 6개와 중복 될 수 없습니다."; + + private final Lotto winningLotto; + private final LottoNumber bonusBall; + + public WinningLotto(Lotto winningLotto, LottoNumber bonusBall) { + validateCheckBonusBallSameWithWinningNumber(winningLotto, bonusBall); + this.winningLotto = winningLotto; + this.bonusBall = bonusBall; + } + + private void validateCheckBonusBallSameWithWinningNumber(Lotto winningLotto, LottoNumber bonusBall) { + if (winningLotto.contains(bonusBall)) { + throw new IllegalArgumentException(PRINT_IF_BONUSBALL_SAME_WITH_WINNING_NUMBER); + } + } + + public ProfitResult getResult(Lottos lottos) { + Map result = getInitialResult(); + for (Lotto lotto : lottos) { + putLottoRankResult(result, lotto); + } + return new ProfitResult(new LottoResult(result), lottos.getCount()); + } + + private void putLottoRankResult(Map result, Lotto lotto) { + int matchCount = lotto.countCommonBalls(winningLotto); + if (!LottoRank.isMatchedCount(matchCount)) { + return; + } + LottoRank rank = getLottoRank(lotto, matchCount); + result.put(rank, result.get(rank) + 1); + } + + private LottoRank getLottoRank(Lotto lotto, int matchCount) { + LottoRank rank = LottoRank.getRank(matchCount, lotto.contains(bonusBall)); + return rank; + } + + private Map getInitialResult() { + Map result = new LinkedHashMap<>(); + for (LottoRank lottoRank : LottoRank.values()) { + result.put(lottoRank, 0); + } + return result; + } +} \ No newline at end of file diff --git a/src/main/java/ui/Printer.java b/src/main/java/ui/Printer.java new file mode 100644 index 0000000..10d94db --- /dev/null +++ b/src/main/java/ui/Printer.java @@ -0,0 +1,54 @@ +package ui; + +import domain.*; + +import java.util.Map; + +public class Printer { + + private static final String PRINT_NUMBER_OF_LOTTO_TICKETS_MESSAGE = "\n수동으로 %d장, 자동으로 %d개를 구매했습니다.\n"; + private static final String PRINT_LOTTO_PROFIT_MESSAGE = "총 수익률은 %.2f입니다."; + private static final String PRINT_WINNING_STATISTICS_MESSAGE = "\n당첨 통계"; + private static final String PRINTER_DIVIDER = "---------"; + private static final String PRINT_LOTTO_MATCHED_LOTTO_RESULT_MESSAGE = "%d개 일치"; + private static final String PRINT_BONUS_BALL_MATCHED_MESSAGE = ", 보너스 볼 일치"; + private static final String PRINT_PRICE_WITH_MATCHED_NUMBER_OF_LOTTOS = " (%d원) - %d개\n"; + private static final String PRINT_PROFIT_LOSS_MESSAGE = "(기준이 1이기 때문에 결과적으로 손해라는 의미임)"; + + public Printer(){ + } + + public void printNumberOfLottoTickets(LottoCount count) { + System.out.print(String.format(PRINT_NUMBER_OF_LOTTO_TICKETS_MESSAGE, count.getManualLottoCount(), count.getAutoLottoCount())); + } + + public void printLottos(Lottos lottos) { + for(Lotto lotto : lottos) { + System.out.println(lotto.getLotto()); + } + } + + public void printLottoProfit(ProfitResult profitResult) { + System.out.println(PRINT_WINNING_STATISTICS_MESSAGE); + System.out.println(PRINTER_DIVIDER); + Map lottoResult = profitResult.getLottoResult(); + for (LottoRank lottoRank : lottoResult.keySet()) { + printLottoMatchedResult(lottoRank, lottoResult.get(lottoRank)); + } + System.out.print(String.format(PRINT_LOTTO_PROFIT_MESSAGE, profitResult.getProfitRate())); + } + + public void printLottoMatchedResult(LottoRank lottoRank, Integer count) { + System.out.print(String.format(PRINT_LOTTO_MATCHED_LOTTO_RESULT_MESSAGE, lottoRank.getMatchCount())); + if (lottoRank == LottoRank.FIVE_MATCH_WITH_BONUS_BALL) { + System.out.print(PRINT_BONUS_BALL_MATCHED_MESSAGE); + } + System.out.print(String.format(PRINT_PRICE_WITH_MATCHED_NUMBER_OF_LOTTOS, lottoRank.getMoney(), count)); + } + + public void printIsLottoProfit(boolean isProfit) { + if(!isProfit) { + System.out.println(PRINT_PROFIT_LOSS_MESSAGE); + } + } +} diff --git a/src/main/java/ui/Receiver.java b/src/main/java/ui/Receiver.java new file mode 100644 index 0000000..c24b295 --- /dev/null +++ b/src/main/java/ui/Receiver.java @@ -0,0 +1,53 @@ +package ui; + +import domain.LottoCount; + +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +public class Receiver { + + private static final String REQUEST_MONEY_MESSAGE = "구입금액을 입력해 주세요."; + private static final String RECEIVE_MANUAL_NUMBER_OF_LOTTO_TICKETS_MESSAGE = "\n수동으로 구매할 로또 수를 입력해 주세요."; + private static final String RECEIVE_MANUAL_LOTTO_NUMBERS = "\n수동으로 구매할 번호를 입력해 주세요."; + private static final String RECEIVE_WINNING_LOTTO_NUMBERS_MESSAGE = "\n지난 주 당첨 번호를 입력해 주세요."; + private static final String RECEIVE_BONUS_BALL_MESSAGE = "보너스 볼을 입력해주세요."; + + private static final Scanner SCANNER = new Scanner(System.in); + + public Receiver() { + } + + public int receiveMoney() { + System.out.println(REQUEST_MONEY_MESSAGE); + return SCANNER.nextInt(); + } + + public int receiveManualNumberOfLottoTickets() { + System.out.println(RECEIVE_MANUAL_NUMBER_OF_LOTTO_TICKETS_MESSAGE); + int manualLottoCount = SCANNER.nextInt(); + SCANNER.nextLine(); + return manualLottoCount; + } + + public List receiveManualLottoNumbers(LottoCount lottoCount) { + System.out.println(RECEIVE_MANUAL_LOTTO_NUMBERS); + List manualLottoNumbers = new ArrayList<>(); + int manualLottoCount = lottoCount.getManualLottoCount(); + for (int i =0; i < manualLottoCount; i++){ + manualLottoNumbers.add(SCANNER.nextLine()); + } + return manualLottoNumbers; + } + + public String receiveWinningLottoNumbers() { + System.out.println(RECEIVE_WINNING_LOTTO_NUMBERS_MESSAGE); + return SCANNER.nextLine(); + } + + public int receiveBonusBall() { + System.out.println(RECEIVE_BONUS_BALL_MESSAGE); + return SCANNER.nextInt(); + } +} diff --git a/src/test/java/LottoCountTest.java b/src/test/java/LottoCountTest.java new file mode 100644 index 0000000..2386899 --- /dev/null +++ b/src/test/java/LottoCountTest.java @@ -0,0 +1,12 @@ +import domain.LottoCount; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + +public class LottoCountTest { + @Test + void 자동로또의_수는_전체_수에서_수동로또의_수를_뺀_것과_같다 () { + LottoCount count = new LottoCount(100, 43); + assertThat(count.getAutoLottoCount()).isEqualTo(57); + } +} diff --git a/src/test/java/LottoRankTest.java b/src/test/java/LottoRankTest.java new file mode 100644 index 0000000..be71558 --- /dev/null +++ b/src/test/java/LottoRankTest.java @@ -0,0 +1,21 @@ +import domain.LottoRank; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + +public class LottoRankTest { + @Test + void 맞은_개수와_등수_확인한다 () { + assertThat(LottoRank.getRank(3, false)).isEqualTo(LottoRank.THREE_MATCH); + assertThat(LottoRank.getRank(3, true)).isEqualTo(LottoRank.THREE_MATCH); + + assertThat(LottoRank.getRank(4, false)).isEqualTo(LottoRank.FOUR_MATCH); + assertThat(LottoRank.getRank(4, true)).isEqualTo(LottoRank.FOUR_MATCH); + + assertThat(LottoRank.getRank(5, false)).isEqualTo(LottoRank.FIVE_MATCH); + assertThat(LottoRank.getRank(5, true)).isEqualTo(LottoRank.FIVE_MATCH_WITH_BONUS_BALL); + + assertThat(LottoRank.getRank(6, false)).isEqualTo(LottoRank.SIX_MATCH); + assertThat(LottoRank.getRank(6, true)).isEqualTo(LottoRank.SIX_MATCH); + } +} diff --git a/src/test/java/LottoResultTest.java b/src/test/java/LottoResultTest.java new file mode 100644 index 0000000..2481e78 --- /dev/null +++ b/src/test/java/LottoResultTest.java @@ -0,0 +1,22 @@ +import domain.LottoRank; +import domain.LottoResult; +import org.junit.jupiter.api.Test; + +import java.util.HashMap; +import java.util.Map; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + +public class LottoResultTest { + @Test + void 전체_이익은_각_로또의_돈과_같다() { + Map rankResult = new HashMap<>(); + rankResult.put(LottoRank.SIX_MATCH, 1); + rankResult.put(LottoRank.FIVE_MATCH_WITH_BONUS_BALL, 3); + rankResult.put(LottoRank.THREE_MATCH, 4); + + LottoResult result = new LottoResult(rankResult); + + assertThat(result.calculateTotalPrize()).isEqualTo(2_000_000_000L + 30_000_000 * 3 + 5_000 * 4); + } +} diff --git a/src/test/java/LottoTest.java b/src/test/java/LottoTest.java new file mode 100644 index 0000000..4056e81 --- /dev/null +++ b/src/test/java/LottoTest.java @@ -0,0 +1,21 @@ +import domain.Lotto; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + +public class LottoTest { + @Test + void getLotto() { + Lotto lotto = Lotto.of("1, 2, 3, 4, 5, 6"); + List lottoData = lotto.getLotto(); + + assertThat((lottoData).contains("1")); + assertThat((lottoData).contains("2")); + assertThat((lottoData).contains("3")); + assertThat((lottoData).contains("4")); + assertThat((lottoData).contains("5")); + assertThat((lottoData).contains("6")); + } +} diff --git a/src/test/java/WinningLottoTest.java b/src/test/java/WinningLottoTest.java new file mode 100644 index 0000000..df30930 --- /dev/null +++ b/src/test/java/WinningLottoTest.java @@ -0,0 +1,20 @@ +import domain.*; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; + +public class WinningLottoTest { + + @Test + void 당첨번호가_로또번호_6개랑_같을_때_예외_메시지_출력() { + Lotto lotto = Lotto.of("1, 2, 3, 4, 5, 6"); + LottoNumber lottoNumber = LottoNumber.of(1); + + assertThatThrownBy(() -> new WinningLotto(lotto, lottoNumber)) + .isInstanceOf(IllegalArgumentException.class); + } +} From 03926933dbd29c10ae9b3a203ebef546699cfe32 Mon Sep 17 00:00:00 2001 From: ichangyu Date: Sun, 11 Apr 2021 07:00:25 +0900 Subject: [PATCH 7/8] =?UTF-8?q?feat:=20empty.txt=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/empty.txt | 0 src/test/java/empty.txt | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/main/java/empty.txt delete mode 100644 src/test/java/empty.txt diff --git a/src/main/java/empty.txt b/src/main/java/empty.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/test/java/empty.txt b/src/test/java/empty.txt deleted file mode 100644 index e69de29..0000000 From 7ea6d895adf8b588ee5f8940a13b0e554dcbbbf2 Mon Sep 17 00:00:00 2001 From: ichangyu Date: Sun, 11 Apr 2021 07:04:17 +0900 Subject: [PATCH 8/8] =?UTF-8?q?refactor:=20out=ED=8F=B4=EB=8D=94=20gitigno?= =?UTF-8?q?re=EC=97=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 573e847..09f21d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea/ .gradle/ build/ +out \ No newline at end of file