电商促销计算类图设计
时间: 2023-12-14 22:34:44 浏览: 34
根据引用内容,电商促销计算类图设计如下:
```mermaid
classDiagram
class Promotion{
-id: int
-name: string
-type: string
-startDate: date
-endDate: date
-status: string
-description: string
+getDiscount(): float
}
class Coupon{
-id: int
-name: string
-type: string
-startDate: date
-endDate: date
-status: string
-description: string
-code: string
+getDiscount(): float
}
class Order{
-id: int
-totalPrice: float
-discount: float
-promotion: Promotion
-coupon: Coupon
+calculateTotalPrice(): float
}
class Customer{
-id: int
-name: string
-email: string
-phone: string
-address: string
+placeOrder(order: Order): bool
}
Promotion <|-- Coupon
Order "1" o-- "1" Promotion
Order "1" o-- "1" Coupon
Customer "1" o-- "*" Order
```
类图中包含四个类:促销类(Promotion)、优惠券类(Coupon)、订单类(Order)和顾客类(Customer)。其中,促销类和优惠券类都有相同的属性和方法,因此可以抽象出一个父类——折扣类(Discount),并将促销类和优惠券类继承自折扣类。订单类包含了订单的基本信息和应用的促销和优惠券信息,可以通过计算得到订单的总价。顾客类可以下订单,将订单信息传递给订单类进行处理。
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)