java实现肯德基收银系统
参考肯德基官网的信息模拟肯德基快餐店的收银系统,合理使用C++或Java或Python结合设计模式(2种以上)至少实现系统的以下功能:
在成都做网站、网站建设中从网站色彩、结构布局、栏目设置、关键词群组等细微处着手,突出企业的产品/服务/品牌,帮助企业锁定精准用户,提高在线咨询和转化,使成都网站营销成为有效果、有回报的无锡营销推广。成都创新互联专业成都网站建设10余年了,客户满意度97.8%,欢迎成都创新互联客户联系。
1.正常餐品结算和找零。
2.基本套餐结算和找零。
3.使用优惠券购买餐品结算和找零。
4.可在一定时间段参与店内活动(自行设计或参考官网信息)。
5.模拟打印小票的功能(写到文件中)。
小票信息保存
class print{ String s=""; //存订单信息 }
食物工厂
interface FoodFactory{ public Hamburger createHamburger(print s,int kind,int num); //生产汉堡包 public Drink createDrink(print s,int kind,int num); //生产饮品 public Chicken createChicken(print s,int kind,int num); //生产鸡肉类 public Sweetmeats createSweetmeats(print s,int kind,int num); //生产甜品 public Snack createSnack(print s,int kind,int num); //生产小吃 public FrenchFries createFrenchFries(print s,int kind,int num); //生产薯条 public SetMeal createSetMeal(print s,int kind,int num); //生产套餐 }
具体食物工厂
interface Hamburger{ public double price(int num); } interface Drink{ public double price(int num); } interface Chicken{ public double price(int num); } interface Sweetmeats{ public double price(int num); } interface Snack{ public double price(int num); } interface FrenchFries{ public double price(int num); } interface SetMeal{ public double price(int num); }
具体食物
//汉堡 //奥尔良烤堡 class Hamburger_1 implements Hamburger{ public double price(int num) { System.out.println("奥尔良烤堡"+" "+" 数量:"+num+" "+"合计:"+(num*8)); return num*8; //返回价格 } } //香辣鸡腿堡 class Hamburger_2 implements Hamburger{ public double price(int num) { System.out.println("香辣鸡腿堡"+" "+" 数量:"+num+" "+"合计:"+(num*9)); return num*9; } } //劲脆鸡腿堡 class Hamburger_3 implements Hamburger{ public double price(int num) { System.out.println("劲脆鸡腿堡"+" "+" 数量:"+num+" "+"合计:"+(num*10)); return num*10; } } //饮品 //橙汁 class Drink_1 implements Drink{ public double price(int num) { System.out.println("橙汁"+" "+" 数量:"+num+" "+"合计:"+(num*7)); return num*7; //返回价格 } } //百事可乐 class Drink_2 implements Drink{ public double price(int num) { System.out.println("百事可乐"+" "+" 数量:"+num+" "+"合计:"+(num*8)); return num*8; } } //百威啤酒 class Drink_3 implements Drink{ public double price(int num) { System.out.println("百威啤酒"+" "+" 数量:"+num+" "+"合计:"+(num*9)); return num*9; } } //鸡肉类 //老北京鸡肉卷 class Chicken_1 implements Chicken{ public double price(int num) { System.out.println("老北京鸡肉卷"+" "+"数量:"+num+" "+"合计:"+(num*9)); return num*9; //返回价格 } } //香辣鸡翅 class Chicken_2 implements Chicken{ public double price(int num) { System.out.println("香辣鸡翅"+" "+"数量:"+num+" "+"合计:"+(num*13)); return num*13; } } //鸡排 class Chicken_3 implements Chicken{ public double price(int num) { System.out.println("鸡排"+" "+"数量:"+num+" "+"合计:"+(num*10)); return num*10; } } //甜品 //原味圣代 class Sweetmeats_1 implements Sweetmeats{ public double price(int num) { System.out.println("原味圣代"+" "+"数量:"+num+" "+"合计:"+(num*9)); return num*9; //返回价格 } } //葡式蛋挞 class Sweetmeats_2 implements Sweetmeats{ public double price(int num) { System.out.println("葡式蛋挞"+" "+"数量:"+num+" "+"合计:"+(num*12)); return num*12; } } //巧克力味华夫 class Sweetmeats_3 implements Sweetmeats{ public double price(int num) { System.out.println("巧克力味华夫"+" "+"数量:"+num+" "+"合计:"+(num*10)); return num*10; } } //小吃 //蔬菜沙拉 class Snack_1 implements Snack{ public double price(int num) { System.out.println("蔬菜沙拉"+" "+"数量:"+num+" "+"合计:"+(num*10)); return num*10; //返回价格 } } //醇香土豆泥 class Snack_2 implements Snack{ public double price(int num) { System.out.println("醇香土豆泥"+" "+"数量:"+num+" "+"合计:"+(num*11)); return num*11; } } //香甜粟米棒 class Snack_3 implements Snack{ public double price(int num) { System.out.println("香甜粟米棒"+" "+"数量:"+num+" "+"合计:"+(num*6)); return num*6; } } //薯条 //波纹霸王薯条 class FrenchFries_1 implements FrenchFries{ public double price(int num) { System.out.println("波纹霸王薯条"+" "+"数量:"+num+" "+"合计:"+(num*12)); return num*12; //返回价格 } } //套餐 //套餐1 class SetMeal_1 implements SetMeal{ public double price(int num) { System.out.println("香辣鸡翅+百事可乐"+" "+"数量:"+num+" "+"合计:"+(num*17)); return num*17; } } //套餐2 class SetMeal_2 implements SetMeal{ public double price(int num) { System.out.println("劲脆鸡腿堡+橙汁"+" "+"数量:"+num+" "+"合计:"+(num*15)); return num*15; } } //套餐3 class SetMeal_3 implements SetMeal{ public double price(int num) { System.out.println("香辣鸡腿堡+百威啤酒+波纹霸王薯条"+" "+"数量:"+num+" "+"合计:"+(num*25)); return num*25; } }
生产具体食物
//生产具体食物 class createFood implements FoodFactory{ print p=new print(); public Hamburger createHamburger(print s,int kind,int num) { if(kind==1){ s.s=s.s+"\n"+"奥尔良汉堡 单价:"+"8"+" 数量:"+num+" 合计:"+(num*8); //将信息保存至s中 return new Hamburger_1();} else if(kind==2) { s.s=s.s+"\n"+"香辣鸡腿堡 单价:"+"9"+" 数量:"+num+" 合计:"+(num*9); return new Hamburger_2();} else if(kind==3) { s.s=s.s+"\n"+"劲脆鸡腿堡 单价:"+"10"+" 数量:"+num+" 合计:"+(num*10); return new Hamburger_3();} else return null; } public Drink createDrink(print s,int kind,int num) { if(kind==1) { s.s=s.s+"\n"+"橙汁 单价:"+"7"+" 数量:"+num+" 合计:"+(num*7); //将信息保存至s中 return new Drink_1();} else if(kind==2) { s.s=s.s+"\n"+"百事可乐 单价:"+"8"+" 数量:"+num+" 合计:"+(num*8); return new Drink_2();} else if(kind==3) { s.s=s.s+"\n"+"百威啤酒 单价:"+"9"+" 数量:"+num+" 合计:"+(num*9); return new Drink_3();} else return null; } public Chicken createChicken(print s,int kind,int num) { if(kind==1) { s.s=s.s+"\n"+"老北京鸡肉卷 单价:"+"9"+" 数量"+num+" 合计:"+(num*9); //将信息保存至s中 return new Chicken_1();} else if(kind==2) { s.s=s.s+"\n"+"香辣鸡翅 单价:"+"13"+" 数量"+num+" 合计:"+(num*13); return new Chicken_2();} else if(kind==3) { s.s=s.s+"\n"+"鸡排 单价:"+"10"+" 数量"+num+" 合计:"+(num*10); return new Chicken_3();} else return null; } public Sweetmeats createSweetmeats(print s,int kind,int num) { if(kind==1) { s.s=s.s+"\n"+"原味圣代 单价:"+"9"+" 数量"+num+" 合计:"+(num*9); //将信息保存至s中 return new Sweetmeats_1();} else if(kind==2) { s.s=s.s+"\n"+"葡式蛋挞 单价:"+"12"+" 数量"+num+" 合计:"+(num*12); return new Sweetmeats_2();} else if(kind==3) { s.s=s.s+"\n"+"巧克力味华夫 单价:"+"10"+" 数量"+num+" 合计:"+(num*10); return new Sweetmeats_3();} else return null; } public Snack createSnack(print s,int kind,int num) { if(kind==1) { s.s=s.s+"\n"+"蔬菜沙拉 单价:"+"10"+" 数量"+num+" 合计:"+(num*10); //将信息保存至s中 return new Snack_1();} else if(kind==2) { s.s=s.s+"\n"+"醇香土豆泥 单价:"+"11"+" 数量"+num+" 合计:"+(num*11); return new Snack_2();} else if(kind==3) { s.s=s.s+"\n"+"香甜粟米棒 单价:"+"6"+" 数量"+num+" 合计:"+(num*6); return new Snack_3();} else return null; } public FrenchFries createFrenchFries(print s,int kind,int num){ if(kind==1) { s.s=s.s+"\n"+"波纹霸王薯条 单价:"+"12"+" 数量"+num+" 合计:"+(num*12); //将信息保存至s中 return new FrenchFries_1();} else return null; } public SetMeal createSetMeal(print s,int kind, int num) { if(kind==1) { s.s=s.s+"\n"+"套餐1 单价:"+"17"+" 数量"+num+" 合计:"+(num*17); //将信息保存至s中 return new SetMeal_1();} else if(kind==2) { s.s=s.s+"\n"+"套餐2 单价:"+"15"+" 数量"+num+" 合计:"+(num*15); return new SetMeal_2();} else if(kind==3) { s.s=s.s+"\n"+"套餐3 单价:"+"25"+" 数量"+num+" 合计:"+(num*25); return new SetMeal_3();} else return null; } }
订购食物,返回价格
class Price{ public FoodFactory create; //构造方法将抽象工厂传入 public Price(FoodFactory create) { this.create=create; } public double orderHamburger(print s,int kind,int num) { Hamburger hamburger=create.createHamburger(s,kind, num); return hamburger.price(num); } public double orderDrink(print s,int kind,int num) { Drink drink=create.createDrink(s,kind, num); return drink.price(num); } public double orderChicken(print s,int kind,int num) { Chicken chicken=create.createChicken(s,kind, num); return chicken.price(num); } public double orderSweetmeats(print s,int kind,int num) { Sweetmeats sweetmeats=create.createSweetmeats(s,kind, num); return sweetmeats.price(num); } public double orderSnack(print s,int kind,int num) { Snack snack=create.createSnack(s,kind, num); return snack.price(num); } public double orderFrenchFries(print s,int kind,int num) { FrenchFries frenchFries=create.createFrenchFries(s,kind, num); return frenchFries.price(num); } public double orderSetMeal(print s,int kind,int num) { SetMeal setMeal=create.createSetMeal(s,kind, num); return setMeal.price(num); } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持创新互联。
新闻标题:java实现肯德基收银系统
URL链接:http://pwwzsj.com/article/pphoig.html