-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCashier.java
More file actions
151 lines (121 loc) · 4.14 KB
/
Cashier.java
File metadata and controls
151 lines (121 loc) · 4.14 KB
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
/*
Copyright (c) 2025 Ahmed R. Sadik, Honda Research Institute Europe GmbH
This source code is licensed under the MIT License found in the
LICENSE file in the root directory of this source tree. This dataset contains smelly code for research and refactoring purposes.
*/
public class Cashier {
private Chef chef;
private boolean frequentCustomerDiscount;
private String firstName;
private String lastName;
private String address;
private String phoneNumber;
private String email;
private String tempDiscountCode;
private String tempOrderNote;
public Cashier(Chef chef) {
this.chef = chef;
this.frequentCustomerDiscount = false;
}
public Chef getChef() {
return this.chef;
}
public void takeOrder(String pizzaType) {
System.out.println("Cashier is taking order for " + pizzaType + " pizza.");
this.chef.bakePizza(pizzaType);
}
public void hurryUpChef() {
System.out.println("Cashier is hurrying up the chef.");
this.chef.hurryUp();
}
public void calmCustomerDown() {
System.out.println("Cashier is calming the customer down.");
this.chef.cleanKitchen();
}
public void deliverPizzaToCustomer() {
System.out.println("Cashier is delivering pizza to the customer.");
}
public void askForReceipt() {
System.out.println("Customer is asking for a receipt.");
}
public void anotherUnusedMethod() {
}
public void longMethod() {
System.out.println("Cashier is handling many tasks in a single method");
this.takeOrder("Cheese");
this.hurryUpChef();
this.calmCustomerDown();
this.deliverPizzaToCustomer();
this.askForReceipt();
}
public void duplicateMethod() {
this.takeOrder("Cheese");
this.takeOrder("Cheese");
}
public void chainOfMethods() {
System.out.println("Cashier is initiating a message chain");
this.chef.cleanKitchen();
}
public void middlemanMethod() {
System.out.println("Cashier is calling a middleman method");
this.middleMethod();
}
public void middleMethod() {
System.out.println("Middleman method delegating to another method");
this.realMethod();
}
public void realMethod() {
System.out.println("Real method doing the actual work");
}
public void updateContactInfo(String firstName, String lastName, String address, String phoneNumber, String email) {
this.firstName = firstName;
this.lastName = lastName;
this.address = address;
this.phoneNumber = phoneNumber;
this.email = email;
}
public void updateName(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public void updateAddress(String address) {
this.address = address;
}
public void updatePhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public void updateEmail(String email) {
this.email = email;
}
public void notifyForPromotion() {
System.out.println("Notifying customer for promotion");
}
public void notifyForDiscount() {
System.out.println("Notifying customer for discount");
}
public void notifyForNewArrivals() {
System.out.println("Notifying customer for new arrivals");
}
public void applyDiscount() {
System.out.println("Applying discount for customer");
}
public void applyLoyaltyPoints() {
System.out.println("Applying loyalty points for customer");
}
public void handleComplaint(String complaint) {
if (complaint.equals("cold pizza")) {
this.calmCustomerDown();
} else if (complaint.equals("late delivery")) {
this.calmCustomerDown();
} else if (complaint.equals("wrong order")) {
this.calmCustomerDown();
} else {
this.calmCustomerDown();
}
}
public void refusedBequest() {
}
public void accessInternalDetails() {
System.out.println("Accessing internal details of Chef: " + chef.isBusy());
}
}