设计模式大题.docxVIP

  • 8
  • 0
  • 约1.18万字
  • 约 16页
  • 2020-04-27 发布于安徽
  • 举报
5.2.某电影院售票系统为不同类型的用户提供了不同的电影票 (CinemaTicket)打折方式 (Discount),学生凭学生证可享受 8 折优惠 (StudentDiscount),儿童可享受减免 10 元的优惠 (ChildrenDiscount), VIP 用户除享受半价优惠外还可以进行积分 (VIPDiscount)。选择一种合 适的设计模式来设计该系统。 ( 策略模式 ) MovieTicket - price : double Discount - discount : Discount + + + setPrice (double price) setDiscount (Discount discount) getPrice () ... : void : void : double + calculate (double price) ... : double StudentDiscount VIPDiscount + calculate (double price) : double + calculate (double price) : double ... ... ChildrenDiscount + calculate (double price) ... : double // 电影票类:环境类 class MovieTicket { priva

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档