Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yujeongkwon #7

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## 입/출력
Copy link

Choose a reason for hiding this comment

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

꼼꼼하시네요!

- [x] 음료 자판기 시작 안내 출력
- [x] 진행 위한 입력 받기
- [x] 차가운/따뜻한 음료 택1 안내 출력
- [x] 차가운/따뜻한 음료 택1 입력 받기
- [x] 위에서 선택한 음료 메뉴 출력
- [x] 사용자의 구매 음료 입렫 받기
- [x] 결제 방식 출력
- [x] 사용자의 결제 방식 입력 받기
- 카드 결제시
- [ ] continue
- 현금 결제시
- [x] 현금 투입 출력
- [ ] 음료 메뉴 가격에 따라 반복
- [x] 현금 투입 입력 받기
- [ ] 투입 금액 출력
- [ ] 이용 감사 안내 출력
- [ ] 주문 음료 출력
- [ ] 잔돈 출력
-
## 자판기
- [x] 음료 메뉴
- [ ] 현금 결제만 가능
- [x] 거스름 돈 반환
- [ ] 돈을 잘못 넣은 경우를 위해 반환 기능
- [ ] 카드 결제 추가
- [x] 10% 부가세 추가 결제
7 changes: 7 additions & 0 deletions src/Application.java
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();
}
}
13 changes: 13 additions & 0 deletions src/main/controller/VendingMachineController.java
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();
}
}
4 changes: 4 additions & 0 deletions src/main/domain/Beverage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package main.domain;

public record Beverage(String name, int price) {
}
17 changes: 17 additions & 0 deletions src/main/domain/Cash.java
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;
Copy link

Choose a reason for hiding this comment

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

UI와 도메인이 커플링이 커보이는데 괜찮을까요?!


public void injectionCash(int inputOption) {
Copy link

Choose a reason for hiding this comment

The 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;
}
}
26 changes: 26 additions & 0 deletions src/main/domain/CashDenomination.java
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;
}
}
14 changes: 14 additions & 0 deletions src/main/domain/Credit.java
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);
}
}
50 changes: 50 additions & 0 deletions src/main/domain/Options.java
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;
}
}
4 changes: 4 additions & 0 deletions src/main/domain/Payment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package main.domain;

public interface Payment {
}
30 changes: 30 additions & 0 deletions src/main/view/InputView.java
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
Copy link

Choose a reason for hiding this comment

The 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();
}
}
Loading