From 1adf7f8e49100de37f090fceb00c40178172f4d4 Mon Sep 17 00:00:00 2001 From: Junhyeok Seo Date: Sun, 26 Nov 2023 14:58:36 +0900 Subject: [PATCH] ZZZ --- Drink.java | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Main.java | 27 ++++++++++++++ Payment.java | 68 ++++++++++++++++++++++++++++++++++++ Product.java | 20 +++++++++++ 4 files changed, 214 insertions(+) create mode 100644 Drink.java create mode 100644 Main.java create mode 100644 Payment.java create mode 100644 Product.java diff --git a/Drink.java b/Drink.java new file mode 100644 index 0000000..67cc190 --- /dev/null +++ b/Drink.java @@ -0,0 +1,99 @@ +import java.util.Scanner; + +public class Drink { + String drinkName; + int price; + int temperature; + + Drink() {} + + Drink(String drinkName, int price, int temperature) { + this.drinkName = drinkName; + this.price = price; + this.temperature = temperature; + } + + Payment payment = new Payment(); + + void drink() { + Payment payment = new Payment(); + + showDrinkList(); + + if (selectDrinkTemperature() == 1) { + showColdDrinkList(); + payment.showPayment(); + + } + + else if (selectDrinkTemperature() == 1) {} + + } + + int userSelectNumber() { + Scanner sc = new Scanner(System.in); + int userSelect = sc.nextInt(); + return userSelect; + } + + + int selectDrinkTemperature() { + int selectNumber = userSelectNumber(); + while(true) { + if (selectNumber != 1 || selectNumber != 2) { + System.out.println("잘못된 입력 입니다."); + } + return setTemperature(selectNumber); + } + + } + + void showDrinkList() { + System.out.println("음료를 선택해 주세요!"); + System.out.println(); + System.out.println("[1] 차가운 음료"); + System.out.println("[2] 따듯운 음료"); + System.out.println(); + System.out.print("사용자 입력 > "); + System.out.println(); + } + + void coldDrink() { + Product product = new Product(); + + } + + void showColdDrinkList() { + Product product = new Product(); + + System.out.println("[차가운 음료]"); + System.out.println(); + for(Long i : product.drinkList.keySet()){ //저장된 key값 확인 + System.out.println("[" + i + "]" + ": " + product.drinkList.get(i) + "원"); + } + System.out.println(); + System.out.print("사용자 입력 > "); + System.out.println(); + } + + + + void orderDrink() { + Payment payment = new Payment(); + System.out.println("[주문 음료]"); + System.out.println(drinkName); + System.out.println("[투입 금액]"); + System.out.println(payment.cashChange + "원"); + System.out.println("[잔돈]"); + + //if + // System.out.println(payment.cashChange - price + "원 동전 :" + + "개"); + } + + + public int setTemperature(int temperature) { + return this.temperature = temperature; + } + + +} diff --git a/Main.java b/Main.java new file mode 100644 index 0000000..0709ee0 --- /dev/null +++ b/Main.java @@ -0,0 +1,27 @@ +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + run(); + } + + static void run() { + final String HELLO_VENDING_MACHINE = "[어서와요! GDSC 음료 자판기]"; + final String ANY_KEY_TO_CONTINUE = "계속 하려면 아무키나 입력하세요 ..."; + final String USER_INPUT = "사용자 입력 > "; + final String LINE = "----------------------------"; + + Scanner sc = new Scanner(System.in); + Drink drink = new Drink(); + + System.out.println(HELLO_VENDING_MACHINE); + System.out.println(ANY_KEY_TO_CONTINUE); + System.out.println(USER_INPUT); + sc.next(); + System.out.println(LINE); + System.out.println(); + + drink.drink(); + } +} + diff --git a/Payment.java b/Payment.java new file mode 100644 index 0000000..f92517d --- /dev/null +++ b/Payment.java @@ -0,0 +1,68 @@ +import java.util.Scanner; + +public class Payment { + String Card; + int cash; + static int cashChange = 0; + + + int showPayment() { + Scanner sc = new Scanner(System.in); + + System.out.println("[결제 방식 선택]"); + System.out.println("[1] 현금"); + System.out.println("[2] 카드 (부가세 10% 적용)"); + System.out.println(); + System.out.print("사용자 입력 > "); + + int select_Payment_Method = sc.nextInt(); + System.out.println(); + System.out.println("----------------------------"); + if(select_Payment_Method != 1 || select_Payment_Method != 2) + System.out.println("잘못된 입력 입니다."); + return select_Payment_Method; + } + + void showCash() { + System.out.println("[현금 투입" + cashChange + "원]"); + System.out.println("[1] 5만원권"); + System.out.println("[2] 1만원권"); + System.out.println("[3] 5천원권"); + System.out.println("[4] 1천원권"); + System.out.println("[5] 500원"); + System.out.println("[6] 100원"); + System.out.println("[0] 반환"); + System.out.println(); + System.out.print("사용자 입력 > "); + //System.out.println("이용해주셔서 감사합니다."); + } + + int insertCash() { + Scanner sc = new Scanner(System.in); + int select_Cash = sc.nextInt(); + System.out.println("----------------------------"); + + if (select_Cash == 1) + return 50000; + else if (select_Cash == 2) + return 10000; + else if (select_Cash == 3) + return 5000; + else if (select_Cash == 4) + return 1000; + else if (select_Cash == 5) + return 500; + else if (select_Cash == 6) + return 100; + return 0; + } + + void selectCard() { + + + } + + + + +} diff --git a/Product.java b/Product.java new file mode 100644 index 0000000..d3bfaa6 --- /dev/null +++ b/Product.java @@ -0,0 +1,20 @@ +import java.util.HashMap; + +public class Product { + HashMap drinkList = new HashMap<>(); + + public Product() { + drinkList.put(1L, new Drink("스프라이트", 1500, 1)); + drinkList.put(2L, new Drink("코카콜라", 1300, 1)); + drinkList.put(3L, new Drink("솔의눈", 1000, 1)); + drinkList.put(4L, new Drink("펩시 콜라", 1100, 1)); + drinkList.put(5L, new Drink("TOP커피", 2500, 2)); + drinkList.put(6L, new Drink("꿀물", 3000, 2)); + drinkList.put(7L, new Drink("홍삼차", 3000, 2)); + drinkList.put(8L, new Drink("단팥죽", 3000, 2)); + } + + + + +} \ No newline at end of file