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

택배송장앱 [STEP 1] Caron #40

Open
wants to merge 13 commits into
base: rft_2_caron
Choose a base branch
from
20 changes: 17 additions & 3 deletions ParcelInvoiceMaker/ParcelInvoiceMaker/ParcelOrderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ enum layoutViewTitle {
static let notice: String = "알림"
}

enum DiscountList {
static let vip = 5 * 4
static let coupon = 2
static let youth = 3
Comment on lines +35 to +38
Copy link

Choose a reason for hiding this comment

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

수식을 따로 선언해보셨네요!👍


}

class NoDiscount: DiscountStrategy {
func applyDiscount(deliveryCost: Int) -> Int {
return deliveryCost
Expand All @@ -40,16 +47,21 @@ class NoDiscount: DiscountStrategy {

class VIPDiscount: DiscountStrategy {
func applyDiscount(deliveryCost: Int) -> Int {
return deliveryCost / 5 * 4
return deliveryCost / DiscountList.vip
}
}

class CouponDiscount: DiscountStrategy {
func applyDiscount(deliveryCost: Int) -> Int {
return deliveryCost / 2
return deliveryCost / DiscountList.coupon
}
}

class YouthDiscount: DiscountStrategy {
func applyDiscount(deliveryCost: Int) -> Int {
return deliveryCost / DiscountList.youth
}
Comment on lines +59 to +62
Copy link

Choose a reason for hiding this comment

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

새로운 할인 정책을 추가해보셨네요!👍


}


class ParcelOrderView: UIView {
Expand Down Expand Up @@ -86,13 +98,15 @@ class ParcelOrderView: UIView {
static let not = "없음"
static let vip = "VIP"
static let coupone = "쿠폰"
static let youth = "청소년"
}

private let discountSegmented: UISegmentedControl = {
let control: UISegmentedControl = .init()
control.insertSegment(withTitle: segmentOption.not, at: 0, animated: false)
control.insertSegment(withTitle: segmentOption.vip, at: 1, animated: false)
control.insertSegment(withTitle: segmentOption.coupone, at: 2, animated: false)
control.insertSegment(withTitle: segmentOption.youth, at: 3, animated: false)
control.selectedSegmentIndex = 0
return control
}()
Expand Down
9 changes: 7 additions & 2 deletions ParcelInvoiceMaker/ParcelInvoiceMaker/ParcelProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ParcelInformation {
}

enum Discount: Int {
case none = 0, vip, coupon
case none = 0, vip, coupon, youth

var strategy: DiscountStrategy {
switch self {
Expand All @@ -38,11 +38,16 @@ enum Discount: Int {
return VIPDiscount()
case .coupon:
return CouponDiscount()
case .youth:
return YouthDiscount()
}
}

}

enum MessageText {
static let saveMsg = "발송 정보를 데이터베이스에 저장했습니다."
}

class ParcelOrderProcessor {

Expand All @@ -66,7 +71,7 @@ class DatabaseParcelInformationPersistence: ParcelInformationPersistence {

func save(parcelInformation: ParcelInformation) {
// 데이터베이스에 주문 정보 저장
print("발송 정보를 데이터베이스에 저장했습니다.")
print(MessageText.saveMsg)
}

}