protocol Shipping {
func calculate(product: Product) -> Int
}
class JNEShipping: Shipping {
func calculate(product: Product) -> Int {
return /** calculate amount of this type with product*/
}
}
class POSINDOShipping: Shipping{
func calculate(product: Product) -> Int {
return /** calculate amount of this type with product*/
}
}
class SiCepatShipping: Shipping{
func calculate(product: Product) -> Int {
return /** calculate amount of this type with product*/
}
}
class ShippingOrderService {
func checkout(product: Product, shipping: Shipping){
let costShipping = shipping.calculate(product: product)
/** Code to do check */
}
}