肯德基收银系统java

参考肯德基官网的信息模拟肯德基快餐店的收银系统,合理使用C++或Java或Python结合设计模式(2种以上)至少实现系统的以下功能:

1.正常餐品结算和找零。

2.基本套餐结算和找零。

3.使用优惠券购买餐品结算和找零。

4.可在一定时间段参与店内活动(自行设计或参考官网信息)。

5.模拟打印小票的功能(写到文件中)。

小票信息保存

class print{
String s=""; //存订单信息
}
1
2
食物工厂

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); //生产套餐
}
1
2
3
4
5
6
7
8
具体食物工厂

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);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
具体食物

//汉堡
//奥尔良烤堡
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;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
生产具体食物

//生产具体食物
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;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
订购食物,返回价格

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);
}
}
--------------------- 

上一篇:《统计学习方法》第三章,k 近邻法


下一篇:Go part 7 反射