Conversation
일부 남음
| TODO("프로그램 구현") | ||
| val eventPlanner = EventPlanner() | ||
| val restaurant = Restaurant(eventPlanner) | ||
| restaurant.open() |
There was a problem hiding this comment.
변수명이나 메서드명이 스토리를 읽는 것 같아서 재밌네요 👍
| init { | ||
| eventPlanner.greeting() | ||
| } |
There was a problem hiding this comment.
인삿말만 init으로 뺀 이유가 있을까요? 없다면 open() 메서드에 포함시켜도 좋을 것 같습니다
| fun checkChristmasDiscount(date: Int): DiscountResult { | ||
| val christmasDiscount = Discount.CHRISTMAS_DISCOUNT.amount + (date - 1) * 100 | ||
| return DiscountResult(Discount.CHRISTMAS_DISCOUNT, christmasDiscount) | ||
| } | ||
|
|
||
| fun checkWeekDiscount(date: Int, order: List<MenuItem>): DiscountResult? { | ||
| val day = Date.getDayOfWeek(date)?.getDateType() | ||
| ?: return null | ||
|
|
||
| val discountAmount = when (day) { | ||
| DateType.WEEKDAY -> Discount.WEEKDAY_DISCOUNT.amount * order.filter { it is MenuItem.Dessert }.size | ||
| DateType.WEEKEND -> Discount.WEEKDAY_DISCOUNT.amount * order.filter { it is MenuItem.Main }.size | ||
| } | ||
|
|
||
| return DiscountResult(discountCode = Discount.WEEKDAY_DISCOUNT, discountAmount = discountAmount, any = day) | ||
| } |
There was a problem hiding this comment.
각 메서드가 enum 각각의 원소와 관련이 있어 보입니다, Discount enum 클래스에 abstract로 녹여낼 수 있을 것 같아요.
| fun findByAmount(amount: Int): RewardBadge? { | ||
| return values().lastOrNull { amount >= it.threshold } | ||
| } |
There was a problem hiding this comment.
enum 원소의 순서에 크게 의존하고 있는 것 같아요. 주석으로 주의를 주거나 해당 방식은 지양하는게 좋을 것 같습니다.
참고: https://stackoverflow.com/questions/3820149/enum-values-is-an-order-of-returned-enums-deterministic
|
|
||
| companion object { | ||
| val event = Event() | ||
| val items = Menu.items |
There was a problem hiding this comment.
여기서 items를 재정의하신 이유가 있을까요?
| println("안녕하세요! 우테코 식당 12월 이벤트 플래너입니다.") | ||
| } | ||
|
|
||
| fun receiveVisitDate(): Int { |
There was a problem hiding this comment.
date는 날짜 전체를 의미하는 것 같아서 dayOfMonth 같은 용어도 괜찮아 보여요
| // private fun getMenuItems(): List<MenuItem> { | ||
| // return eventPlanner.takeOrder().flatMap { orderItem -> | ||
| // val itemName = orderItem[0] | ||
| // val quantity = orderItem[1].toInt() | ||
| // | ||
| // List(quantity) { items.find { item -> item.name == itemName }!! } | ||
| // } | ||
| // } |
1jeongg
left a comment
There was a problem hiding this comment.
이번주도 고생 많으셨어요~!! 메뉴가 주말/주중 구분에서 깔끔하게 카테고리별로 분류하신 점이 인상깊었어요! 👍👍
맥북.. 제가 다 마음이 아프네요 ㅠㅠ
다음주도 화이팅입니다 🔥🔥
| class Drink(name: String, price: Int) : MenuItem(name, price) | ||
| } | ||
|
|
||
| object Menu { |
There was a problem hiding this comment.
오 이런식으로 사용하니까 카테고리별로 보기 쉽네요! 👍👍
| fun getMenuItems(): List<MenuItem> { | ||
| while (true) { | ||
| val orderItems = eventPlanner.takeOrder() | ||
|
|
||
| if (orderItems.distinctBy { it[0] }.size < orderItems.size) { | ||
| println("[ERROR] 유효하지 않은 주문입니다. 다시 입력해 주세요.") | ||
| continue | ||
| } | ||
|
|
||
| val menuItems = orderItems.flatMap { orderItem -> | ||
| val itemName = orderItem[0] | ||
| val quantity = orderItem.getOrNull(1)?.toIntOrNull() | ||
|
|
||
| if (quantity == null || quantity < 1 || items.none { it.name == itemName }) { | ||
| println("[ERROR] 유효하지 않은 주문입니다. 다시 입력해 주세요.") | ||
| return@getMenuItems listOf<MenuItem>() | ||
| } | ||
|
|
||
| List(quantity) { items.find { item -> item.name == itemName }!! } | ||
| } | ||
|
|
||
| return menuItems | ||
| } | ||
| } |
There was a problem hiding this comment.
이번 요구사항에 함수는 15라인 이하라고 되어있어서 분리하는게 좋을 것 같아요! 그리고 잘못된 값을 입력하면 IllegalArgumentException을 발생시켜야된다고도 나와있어요!
| } | ||
|
|
||
| fun receiveVisitDate(): Int { | ||
| println("12월 중 식당 예상 방문 날짜는 언제인가요? (숫자만 입력해 주세요!)") |
There was a problem hiding this comment.
이건 선택적일 수 있긴 하지만 이벤트 목표에 12월 이벤트 참여 고객의 5%가 내년 1월 새해 이벤트에 재참여하는 것 이 있어서 몇 월인지 계속 바뀔 수 있으니까 12월도 MAGIC_NUMBER로 빼두면 어떨까요?
| class Event { | ||
| enum class Discount(val description: String, val amount: Int) { | ||
| CHRISTMAS_DISCOUNT("크리스마스 디데이 할인", 1000), | ||
| WEEKDAY_DISCOUNT("평일 할인", 2023), |
| totalPrice: Int | ||
| ): List<DiscountResult> { | ||
| if (totalPrice <= 10_000) { | ||
| return listOf() |
There was a problem hiding this comment.
빈 리스트를 반환하고 싶다면 가독성을 위해 emptyList()는 어떨까요?
구현하면서 고민되었던 점
자랑하고 싶은 점
죄송한점
나름의 변명...
어.. 제가 주말에 맥북을.. 온천천에서 떨어뜨려서 멘탈이 조금 바사사삭...됐습니다.. 하핫
미안합니닷..!
리뷰 하고싶은데 코드가 안올라와서 속상하실까봐 미리 pr 올려둡니닷..!