KFC cash register system java

Information Reference KFC official website analog KFC cash register system, the rational use C ++ or Python or Java design patterns (two or more kinds) implementation of the system at least the following functions:

1. Normal settlement food products and give change.

2. The basic package settlement and give change.

3. Use the coupons to purchase food products settlement and give change.

4 can store events involved in a certain period of time (refer to the official network designed or information).

5. Analog small ticket printing function (written to a file).

Small ticket information is stored

Print {class
String S = ""; // save the order information
}
. 1
2
food factories

{FoodFactory interface
public Hamburger createHamburger (Print S, kind int, int NUM); // producing hamburgers
public Drink createDrink (print s, int kind, int num); // beverage production
public Chicken createChicken (print s, int kind, int num); // producing chicken
public sweetmeats createSweetmeats (print s, int kind, int num); // dessert production
public snack createSnack (print s, int kind, int num); // snack production
public frenchFries createFrenchFries (print s , int kind, int num); // production fries
public SetMeal createSetMeal (print s, int kind, int num); // Package production
}
. 1
2
. 3
. 4
. 5
. 6
. 7
. 8
concrete plant food

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
specific food

// Hamburg
// Fort Orleans roast
class Hamburger_1 the implements Hamburger {
public. Price Double (int NUM)
{
System.out.println ( "Fort Orleans roast" + "" + "number:" + num + "" + " Total:" + (NUM *. 8));
return NUM *. 8; // return price
}
}
// spicy chicken burger
class Hamburger_2 the implements Hamburger {
public. price Double (int NUM)
{
System.out.println ( "spicy chicken burger" + "" + "number:" + num + "" + " total:" + (NUM *. 9));
return NUM *. 9;
}
}
// fresh crisp chicken burger
class Hamburger_3 the implements Hamburger {
public Double. price (int NUM)
{
System.out.println ( "fresh crisp chicken burger" + "" + "number:" + num + "" + " total:"+ (NUM * 10));
return NUM * 10;
}
}
// drinks
// orange juice
Drink_1 the implements. Drink. {class
public. price Double (int NUM)
{
System.out.println ( "orange" + "" + "Number:" + num + "" + " Total:" + (NUM *. 7));
return NUM * 7; // return price
}
}
// Pepsi
class Drink_2 the implements. Drink. {
public. price Double (int NUM)
{
System.out.println ( "Pepsi" + "" + "number:" NUM + + "" + "total:" + (NUM *. 8));
return NUM *. 8;
}
}
// Budweiser
class Drink_3 the implements. Drink. {
public. price Double (int NUM)
{
System.out.println ( "Budweiser" + "" + "the number of : "+ num +" "+ " total: "+ (NUM * 9));
return NUM * 9;
}
}
// Chicken
// Old Beijing Chicken Roll
class Chicken_1 implements Chicken {
Double. price public (int NUM)
{
System.out.println ( "Old Beijing Chicken Roll" + "" + "number:" + num + "" + " Total:" + (NUM * 9));
return NUM * 9; // return price
}
}
// spicy chicken wings
class Chicken_2 the implements Chicken {
public. price Double (int NUM)
{
System.out.println ( "spicy chicken wings" + "" + "number:" + num + "" + " total : "+ (* 13 is NUM));
return 13 is NUM *;
}
}
// chicken
class Chicken_3 the implements chicken {
public. price Double (int NUM)
{
System.out.println (" chicken "+" "+" the number of : "+ num +" "+ " total: "+ (NUM * 10));
return NUM * 10;
}
}
// desserts
// flavor sundae
class Sweetmeats_1 the implements sweetmeats {
public. Price Double (int NUM)
{
System.out.println ( "Original Sundae" + "" + "number:" + num + "" + " Total:" + (NUM * 9));
return NUM * 9; // return price
}
}
// Portugal formula tart
class Sweetmeats_2 the implements sweetmeats {
public. price Double (int NUM)
{
System.out.println ( "Portuguese egg tart" + "" + "number:" + num + "" + " total:" + (num * 12) ) ;
return 12 is NUM *;
}
}
// chocolate waffle
class Sweetmeats_3 the implements sweetmeats {
public. price Double (int NUM)
{
System.out.println ( "chocolate waffle" + "" + "number:" + num + " "+" total: "+ (NUM * 10));
return NUM * 10;
}
}
// snacks
// salad
class Snack_1 the implements the Snack {
public. Price Double (int NUM)
{
System.out.println ( "green salad" + "" + "number:" + num + "" + " Total:" + (NUM * 10));
return NUM * 10; // return price
}
}
// mellow potatoes mud
class Snack_2 the implements the Snack {
public. price Double (int NUM)
{
System.out.println (+ "" + "number" mellow mashed potatoes ":" + num + "" + " total:" + (num * 11) );
NUM *. 11 return;
}
}
// sweet corn rod
class Snack_3 the implements the Snack {
public. price Double (int NUM)
{
System.out.println ( "sweet corn stick" + "" + "number:" + num + "" + " total: "+ (NUM * 6));
return NUM * 6;
}
}
// fries
// King corrugated chips
class FrenchFries_1 the implements frenchfries {
public. Price Double (int NUM)
{
System.out.println ( "ripple King fries" + "" + "number:" + num + "" + " Total:" + (NUM * 12));
return NUM * 12; // return price
}
}
// Package
// Package 1
class SetMeal_1 the implements SetMeal {
public. price Double (int NUM) {
System.out.println ( "spicy chicken wings + Pepsi" + "" + "number:" + num + "" + " total:" + ( *. 17 NUM));
return NUM *. 17;
}
}
// Package 2
class SetMeal_2 the implements SetMeal {
public. price Double (int NUM) {
System.out.println ( "crisp chicken burger fresh orange juice +" + "" + "the number of : "+ num +" "+ " total: "+ (NUM * 15));
return NUM * 15;
}
}
// package. 3
class SetMeal_3 the implements SetMeal {
public. Price Double (int NUM) {
System.out.println ( "spicy chicken burger + + corrugated Budweiser King fries" + "" + "Number:" + num + "" + "total:" + (num * 25) );
Surely return 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 And
53 The
54 The
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
1 16
117
1 18
119
120
121
122
123
124
125
126
127
128
129
130.
131 is
132
133
134
135
136
137
138
139
140
141 is
142
143
144
145
146
147
148
149
150
151
152
153
154
155
Production particular food

Specific food production //
class createFood the implements FoodFactory {
Print Print new new P = ();
public Hamburger createHamburger (Print S, kind int, int NUM) {
IF (== kind. 1) {
SS = S.S. + "\ n-" + "Orléans Hamburg Price:" + "8" + "number:" NUM + + "total:" + (num * 8) ; // save the information to the s
return new new Hamburger_1 ();}
the else IF (kind == 2 ) {
SS = S.S. + "\ n-" + "spicy chicken burger Price:" + "9" + "number:" NUM + + "total:" + (NUM * 9);
return new new Hamburger_2 ();}
the else IF (== kind. 3) {
SS = S.S. + "\ n-'+' fresh crisp chicken burger Price:" + "10" + "number:" NUM + + "total:" + (10 * NUM);
return new new Hamburger_3 ();}
the else return null;
}
public. Drink. createDrink (Print S, int kind,NUM int) {
IF (== kind. 1) {
SS = S.S. + "\ n-'+' orange Price:" + "7" + "Number:" NUM + + "Total:" + (num * 7) ; / / s to save the information in the
new new Drink_1 return ();}
the else IF (kind == 2) {
SS = S.S. + "\ n-" + "Pepsi Price:" + "8" + "Number:" NUM + + "Total:" + (num * . 8);
return new new Drink_2 ();}
the else IF (== kind. 3) {
SS = S.S. + "\ n-'+' Budweiser Price:" + "9" + "number:" NUM + + "total: "+ (NUM *. 9);
return new new Drink_3 ();}
the else return null;
}
public Chicken createChicken (Print S, kind int, int NUM) {
IF (== kind. 1) {
SS = S.S. +" \ n- "+" old Beijing chicken roll Price: "+" 9 "+" number "+ + num" total: "+ (num * 9) ; // save the information to s in
return new new Chicken_1 ();}
the else IF (kind 2 ==) {
SS = S.S. + "\ n-" + "spicy chicken wings Price:" + "13" + "the number of" + + NUM "total:" + (num * 13) ;
new new Chicken_2 return ();}
the else IF (== kind. 3) {
+ "chicken Price:" ss = s.s + "\ n" + "10" + " the number of" + num + "Total:" + (num * 10);
return new new Chicken_3 ();}
return null the else;
}
public sweetmeats createSweetmeats (Print S, kind int, int NUM) {
IF (== kind. 1) {
SS = S.S. + "\ n-" + "flavor Sundae Price:" + "9" + " number of "+ num +" total: "+ (num * 9) ; // save the information to the s
return new new Sweetmeats_1 ();}
the else IF (kind == 2) {
SS = S.S. +" \ n-"+" Portuguese egg tart Price: "+" 12 "+" the number of "+ + NUM" total: "+ (12 * NUM);
return new new Sweetmeats_2 ();}
the else IF (== kind. 3) {
SS = S.S. +" \ n "+" chocolate waffle Price: "+" 10 "+" the number of "+ NUM +" total: "+ (NUM * 10);
return new new Sweetmeats_3 ();}
the else return null;
}
public the Snack createSnack (Print S , kind int, int NUM) {
IF (== kind. 1) {
SS = S.S. + "\ n-" + "Vegetable salad Price: "+" 10 "+" the number of "+ + NUM" Total: "+ (num * 10) ; // save the information to the s
return new new Snack_1 ();}
the else IF (kind == 2) {
ss = s.s + "\ n" + " mellow mashed potatoes Price:" + "11" + "the number of" + NUM + "Total:" + (NUM * 11);
return new new Snack_2 ();}
the else IF (kind = =. 3) {
SS = S.S. + "\ n-" + "sweet corn stick Price:" + "6" + "the number of" + NUM + "total:" + (NUM * 6);
return new new Snack_3 ();}
the else null return;
}
public frenchfries createFrenchFries (Print S, kind int, int NUM) {
IF (== kind. 1) {
SS = S.S. + "\ n-" + "corrugation King fries Price:" + "12" + " number of "+ num +" total: "+ (num * 12) ; // save the information to the in s
() return new new FrenchFries_1;}
the else return null;
}
public SetMeal createSetMeal (Print s, int kind, int NUM) {
IF (kind == 1) {
SS = S.S. + "\ n-" + "Price Package 1:" + "17" + "Number of "+ num +" Total: "+ (num * 17) ; // save the information to the s
return new new SetMeal_1 ();}
the else IF (kind == 2) {
ss = s.s + "\ n" + " Price Package 2:" + "15" + "the number of" + + NUM "Total:" + (15 * NUM);
return new new SetMeal_2 ();}
the else IF (kind == 3) {
SS = S.S. + "\ n-" + "Package 3 Price:" + "25" + "the number of" + NUM + "total:" + (NUM * 25);
return new new SetMeal_3 ();}
the 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 is
39
40
41 is
42 is
43 is
44 is
45
46 is
47
48
49
50
51 is
52 is
53 is
54 is
55
56 is
57 is
58
59
60
61 is
62 is
63 is
64
65
66
67
68
69
70
71 is
72
73 is
74
75
76
77
78
79
80
81
Usually food, returns the price

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

Guess you like

Origin www.cnblogs.com/ly570/p/10954537.html
KFC