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

[팀 A - 김수현] 1차 코드 리뷰 요청 #2

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
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.

6 changes: 6 additions & 0 deletions .idea/jpa-buddy.xml

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.

63 changes: 63 additions & 0 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import domain.PaymentMethod;
import domain.Product;
import domain.UserType;
import service.*;
import util.message.SystemMessage;

import static domain.Temperature.*;
import static domain.UserType.*;

public class Main {
private static ProductService productService;
private static SystemMessage systemMessage;
private static UserService userService;
private static AdminService adminService;

public static void main(String[] args) {
UserType user = USER;
initialize();
systemMessage.welcome();
String input;
input = systemMessage.inputMessage(user);
if (input.equals("admin")) {
user = ADMIN;

return;
}
systemMessage.printTemperatureMenu();
userService.selectTemperature(systemMessage.inputMessage(user));
Product product = userService.selectProduct(systemMessage.inputMessage(user));

systemMessage.printPaymentMethodMenu();

PaymentMethod paymentMethod = userService.selectPaymentMethod(systemMessage.inputMessage(user), product);
if (paymentMethod.equals(PaymentMethod.CASH)) {
int insertedCash = userService.insertCash(product);
systemMessage.cashResult(product, insertedCash);
} else if (paymentMethod.equals(PaymentMethod.CARD)) {
systemMessage.cardResult(product);
} else {
System.out.println("잘못된 입력값");
}
}

public static void initialize() {
productService = new ProductServiceImpl();
systemMessage = new SystemMessage();
userService = new UserServiceImpl(productService, systemMessage);
adminService = new AdminServiceImpl(productService, systemMessage);

initData();
}

public static void initData() {
Product product1 = new Product(COLD, "스프라이트", 1500);
productService.addProduct(product1);
Product product2 = new Product(COLD, "코카콜라", 1500);
productService.addProduct(product2);
Product product3 = new Product(COLD, "솔의 눈", 1500);
productService.addProduct(product3);
Product product4 = new Product(HOT, "팥죽", 1500);
productService.addProduct(product4);
}
}
23 changes: 23 additions & 0 deletions src/domain/MoneyType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package domain;

import java.util.List;

public enum MoneyType {
PAPER_50000("5만원권"),
PAPER_10000("1만원권"),
PAPER_5000("5천원권"),
PAPER_1000("1천원권"),
COIN_500("5백원 동전"),
COIN_100("1백원 동전"),
;

private String money;

MoneyType(String money) {
this.money = money;
}

public String getMoney() {
return money;
}
}
17 changes: 17 additions & 0 deletions src/domain/PaymentMethod.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package domain;

public enum PaymentMethod {
CASH("현금"),
CARD("카드"),
;

private String paymentMethod;

PaymentMethod(String paymentMethod) {
this.paymentMethod = paymentMethod;
}

public String getPaymentMethod() {
return paymentMethod;
}
}
39 changes: 39 additions & 0 deletions src/domain/Product.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package domain;

public class Product {
private Long productId;
private Temperature temperature;
private String productName;
private Integer cost;

public Product(Temperature temperature, String productName, Integer cost) {
this.temperature = temperature;
this.productName = productName;
this.cost = cost;
}

public Long getProductId() {
return productId;
}

public void setProductId(Long productId) {
this.productId = productId;
}

public Temperature getTemperture() {
return temperature;
}

public String getProductName() {
return productName;
}

public Integer getCost() {
return cost;
}

@Override
public String toString() {
return String.format("[%d] %s : %d\n", productId, productName, cost);
}
}
15 changes: 15 additions & 0 deletions src/domain/Temperature.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package domain;

public enum Temperature {
COLD("차가운 음료"), HOT("따뜻한 음료");

private String temperature;

Temperature(String temperature) {
this.temperature = temperature;
}

public String getTemperature() {
return temperature;
}
}
5 changes: 5 additions & 0 deletions src/domain/UserType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package domain;

public enum UserType {
USER, ADMIN;
}
15 changes: 15 additions & 0 deletions src/repository/ProductRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package repository;

import domain.Product;

import java.util.List;

public interface ProductRepository {
void add(Product product);

void delete(Long productId);

Product findByProductId(Long productId);

List<Product> findAllProducts();
}
Loading