欢迎来到天天文库
浏览记录
ID:53047224
大小:1.15 MB
页数:23页
时间:2020-03-31
《设计模式大作业-蛋糕预定系统实验报告.docx》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、蛋糕订购系统蛋糕订购系统23蛋糕订购系统一、实验介绍………………………………………………3二、实验环境………………………………………………3三、系统流程………………………………………………3四、系统总类图………………………………………………4五、程序源代码及各个模块子类图………………………………………………5六、程序运行截图…………………………………………….22七、实验总结…………………………………………….2223蛋糕订购系统一、实验介绍本系统使用了简单工厂模式、工厂方法模式、单例模式、门面模式、策略模式、观察者
2、模式一共6种模式实现了从蛋糕店订购订购蛋糕的这样一个系统。二、实验环境Windows操作系统、MyEclipse10.0、MySQL5.5、jdk1.6三、系统流程四、系统总类图23蛋糕订购系统一、程序源代码及各个模块子类图(一)测试类Client.java:packagenet.xsl.ordercake.test;importnet.xsl.ordercake.discount.DiscountStyleThree;importnet.xsl.ordercake.discount.OrderCake;import
3、net.xsl.ordercake.order.CakeShop;importnet.xsl.ordercake.order.EastVilla;importnet.xsl.ordercake.order.WestVilla;publicclassClient{publicstaticvoidmain(Stringarg[]){CakeShopstarCakeShop=CakeShop.getCakeShop();newWestVilla(starCakeShop,"草莓水果");starCakeShop.getNe
4、wName("西13");starCakeShop.notifyCustomer();OrderCakecake=newOrderCake();System.out.println("今日促销一律8折优惠");cake.setM(8);cake.setStyle(newDiscountStyleThree());cake.setPrice(80);System.out.println("本次订购成功完成,需要支付的金额为23蛋糕订购系统"+cake.getMoney(cake.getPrice(),cake.getM
5、())+",原价80");System.out.println("=================================");newEastVilla(starCakeShop,"甜奶");starCakeShop.getNewName("东18");starCakeShop.notifyCustomer();System.out.println("=================================");starCakeShop.getNewName("东12");starCakeShop
6、.notifyCustomer();}}(一)折扣的接口和方法(策略模式):a)接口DiscountStyle.java:packagenet.xsl.ordercake.discount;publicinterfaceDiscountStyle{publicdoubledisCount(doubleprice,doublem);}b)折方式一DiscountStyleOne.java:packagenet.xsl.ordercake.discount;publicclassDiscountStyleOneimple
7、mentsDiscountStyle{publicdoubledisCount(doubleprice,doublem){returnprice;23蛋糕订购系统}}a)打折方式二DiscountStyleTwo.java:packagenet.xsl.ordercake.discount;publicclassDiscountStyleTwoimplementsDiscountStyle{publicdoubledisCount(doubleprice,doublem){price=price-m;returnpr
8、ice;}}b)打着方式三DiscountStyleThree.java:packagenet.xsl.ordercake.discount;publicclassDiscountStyleThreeimplementsDiscountStyle{publicdoubledisCount(doubleprice,doublem){price=p
此文档下载收益归作者所有