Skip to content

Conversation

@tiemo0708
Copy link

No description provided.

Copy link

@Dompoo Dompoo left a comment

Choose a reason for hiding this comment

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

고생하셨습니다! 스터디에서 봬요!

Comment on lines +20 to +22
if (orderItems.stream().anyMatch(item -> item.getMenu().getCategory().equals("음료") && orderItems.size() == 1)) {
throw new IllegalArgumentException("[ERROR] 음료만 주문할 수 없습니다.");
}
Copy link

Choose a reason for hiding this comment

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

음료를 1개만 주문했을 때는 잘 걸릴 것 같은데, 음료만 2개 주문하면 통과될 것 같아요!

CHAMPAGNE("샴페인", "음료", BigDecimal.valueOf(25_000));

private final String name;
private final String category;
Copy link

Choose a reason for hiding this comment

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

카테고리는 분류가 정해져있으니까, Enum으로 관리하면 더 좋을 것 같아요!

Comment on lines +10 to +15
public BigDecimal applyDiscount(Order order, int date) {
if (date >= 1 && date <= 25) {
BigDecimal discountAmount = BigDecimal.valueOf(1000 + (date - 1) * 100);
return discountAmount.min(order.getTotalPriceBeforeDiscount());
}
return BigDecimal.ZERO;
Copy link

Choose a reason for hiding this comment

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

어디서 봤는지 기억은 안나는데, 이런 if 구조에서
1~25일 사이인게 메인이잖아요? 그러면 그 외의 것을 if문 안에 넣어서 탈출시키는 방식으로 주요 코드를 indent 1에 계속 두는 것이 더 읽기 좋은 코드를 짠다고 들은 적이 있어요.

if (date < 1 || date > 25) {
    return BigDecimal.ZERO;
}
BigDecimal discountAmount = BigDecimal.valueOf(1000 + (date - 1) * 100);
return discountAmount.min(order.getTotalPriceBeforeDiscount());

그래야 if문이 많이 중첩되는 경우에도 흐름을 따라가기 쉽다고 하더라고요!

Comment on lines +8 to +15
private static final int GIFT_THRESHOLD = 120_000;

public Menu checkGiftEligibility(Order order) {
if (order.getTotalPriceBeforeDiscount().compareTo(new java.math.BigDecimal(GIFT_THRESHOLD)) >= 0) {
return Menu.CHAMPAGNE;
}
return null;
}
Copy link

Choose a reason for hiding this comment

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

Gift도 DiscountPolicy처럼 관리했으면 더 좋았을 것 같아요!
지금은 너무 하드코딩 되어서 나중에 다른 Gift를 추가하고 싶어도 고칠 것이 많아 보입니닷.

Comment on lines +40 to +56
private Badge assignBadge(BigDecimal totalDiscount, Menu gift) {
BigDecimal totalBenefit = totalDiscount;
if (gift != null) {
totalBenefit = totalBenefit.add(gift.getPrice());
}

if (totalBenefit.compareTo(new BigDecimal("20000")) >= 0) {
return Badge.SANTA;
}
if (totalBenefit.compareTo(new BigDecimal("10000")) >= 0) {
return Badge.TREE;
}
if (totalBenefit.compareTo(new BigDecimal("5000")) >= 0) {
return Badge.STAR;
}
return Badge.NONE;
}
Copy link

Choose a reason for hiding this comment

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

요 로직은 Badge의 내부 구현이라고 생각해서, Badge가 직접 처리해도 좋을 것 같은데, 어떻게 생각하시나요?

Comment on lines +7 to +15
public String readDate() {
System.out.println("안녕하세요! 우테코 식당 12월 이벤트 플래너입니다.");
System.out.println("12월 중 식당 예상 방문 날짜는 언제인가요? (숫자만 입력해 주세요!)");
return Console.readLine();
}
public String readOrder() {
System.out.println("주문하실 메뉴와 개수를 입력해 주세요. (e.g. 해산물파스타-2,레드와인-1,초코케이크-1)");
return Console.readLine();
}
Copy link

Choose a reason for hiding this comment

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

요구사항을 잘 보시면, 1월에도 이벤트를 계속 진행할 것 처럼 적혀있어요.
12월로 하드코딩하지 않고, 값을 외부에서 주입받도록 하는 것이 좋아 보입니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants