-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Yujeongkwon #7
base: main
Are you sure you want to change the base?
Yujeongkwon #7
Changes from all commits
71c3403
64e9418
e9e2dce
839516f
025ceb7
6eb3ead
d88b949
ad75ab6
4f5d42b
1b97314
5dbccef
6ed77e9
8784df4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
## 입/출력 | ||
- [x] 음료 자판기 시작 안내 출력 | ||
- [x] 진행 위한 입력 받기 | ||
- [x] 차가운/따뜻한 음료 택1 안내 출력 | ||
- [x] 차가운/따뜻한 음료 택1 입력 받기 | ||
- [x] 위에서 선택한 음료 메뉴 출력 | ||
- [x] 사용자의 구매 음료 입렫 받기 | ||
- [x] 결제 방식 출력 | ||
- [x] 사용자의 결제 방식 입력 받기 | ||
- 카드 결제시 | ||
- [ ] continue | ||
- 현금 결제시 | ||
- [x] 현금 투입 출력 | ||
- [ ] 음료 메뉴 가격에 따라 반복 | ||
- [x] 현금 투입 입력 받기 | ||
- [ ] 투입 금액 출력 | ||
- [ ] 이용 감사 안내 출력 | ||
- [ ] 주문 음료 출력 | ||
- [ ] 잔돈 출력 | ||
- | ||
## 자판기 | ||
- [x] 음료 메뉴 | ||
- [ ] 현금 결제만 가능 | ||
- [x] 거스름 돈 반환 | ||
- [ ] 돈을 잘못 넣은 경우를 위해 반환 기능 | ||
- [ ] 카드 결제 추가 | ||
- [x] 10% 부가세 추가 결제 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import main.controller.VendingMachineController; | ||
|
||
public class Application { | ||
public static void main(String[] args) { | ||
new VendingMachineController().start(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package main.controller; | ||
|
||
import main.view.OutputView; | ||
|
||
public class VendingMachineController { | ||
public void start() { | ||
set(); | ||
} | ||
|
||
private void set() { | ||
OutputView.printWelcomeMessage(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package main.domain; | ||
|
||
public record Beverage(String name, int price) { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package main.domain; | ||
|
||
import java.util.Arrays; | ||
|
||
public class Cash implements Payment{ | ||
private int cashInput = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UI와 도메인이 커플링이 커보이는데 괜찮을까요?! |
||
|
||
public void injectionCash(int inputOption) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 메서드 명은 동사로 하면 좋을 것 같아요! |
||
Arrays.stream(CashDenomination.values()) | ||
.filter(denomination -> denomination.getOption() == inputOption) | ||
.forEach(denomination -> cashInput += denomination.getValue()); | ||
} | ||
|
||
private int calculateChange(int price) { | ||
return price - cashInput; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main.domain; | ||
|
||
public enum CashDenomination { | ||
FIFTY_THOUSAND_WON(1, 50000), | ||
TEN_THOUSAND_WON(2, 10000), | ||
FIVE_THOUSAND_WON(3, 5000), | ||
ONE_THOUSAND_WON(4, 1000), | ||
FIVE_HUNDRED_WON(5, 500), | ||
ONE_HUNDRED_WON(6, 100); | ||
|
||
private final int option; | ||
private final int value; | ||
|
||
CashDenomination(int option, int value) { | ||
this.option = option; | ||
this.value = value; | ||
} | ||
|
||
public int getOption() { | ||
return option; | ||
} | ||
|
||
public int getValue() { | ||
return value; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package main.domain; | ||
|
||
public class Credit { | ||
private final double FEE = 0.1; | ||
private final int amount; | ||
|
||
public Credit(int price) { | ||
this.amount = price; | ||
} | ||
|
||
public int getPaymentAmount() { | ||
return (int) (amount + amount * FEE); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package main.domain; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public enum Options { | ||
COLD("차가운 음료",List.of( | ||
new Beverage("스프라이트 ", 1500), | ||
new Beverage("코카콜라", 1300), | ||
new Beverage("솔의눈 ", 1000), | ||
new Beverage("펩시 콜라 ", 1100) | ||
)), | ||
HOT("따뜻한 음료", List.of( | ||
new Beverage("TOP커피", 1800), | ||
new Beverage("꿀물", 1500), | ||
new Beverage("홍삼차 ", 1700), | ||
new Beverage("단팥죽 ", 2100) | ||
)); | ||
|
||
private static final Map<String, Options> beverageToOptions = new HashMap<>(); | ||
|
||
static { | ||
for (Options menu : Options.values()) { | ||
for (Beverage food : menu.beverages) { | ||
beverageToOptions.put(food.name(), menu); | ||
} | ||
} | ||
} | ||
|
||
private final String options; | ||
private final List<Beverage> beverages; | ||
|
||
Options(String options, List<Beverage> beverages) { | ||
this.options = options; | ||
this.beverages = beverages; | ||
} | ||
|
||
public static Options getUserSelectedOption(int userInput) { | ||
return Options.values()[userInput - 1]; | ||
} | ||
|
||
public String getOptions() { | ||
return options; | ||
} | ||
|
||
public List<Beverage> getBeverages() { | ||
return beverages; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package main.domain; | ||
|
||
public interface Payment { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main.view; | ||
|
||
import java.util.Scanner; | ||
|
||
public class InputView { | ||
private static final Scanner scanner = new Scanner(System.in); | ||
|
||
public static String readContinueStatus(Scanner scanner) { | ||
System.out.println("계속 하려면 아무키나 입력하세요 ..."); | ||
return scanner.nextLine(); | ||
} | ||
|
||
public static int readBeverageOption(Scanner scanner) { | ||
System.out.print("사용자 입력 >"); | ||
return scanner.nextInt(); | ||
} | ||
|
||
public static int readBeverageNumber(Scanner scanner) { | ||
System.out.print("사용자 입력 >"); | ||
return scanner.nextInt(); | ||
} | ||
Comment on lines
+13
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 분리했을 때 장단점이 어떻게 될까요? |
||
|
||
public static int getPaymentOption(Scanner scanner) { | ||
return scanner.nextInt(); | ||
} | ||
|
||
public static int getCashOption(Scanner scanner) { | ||
return scanner.nextInt(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
꼼꼼하시네요!