-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSeniorCustomer.cpp
More file actions
136 lines (115 loc) · 5.7 KB
/
SeniorCustomer.cpp
File metadata and controls
136 lines (115 loc) · 5.7 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
#include "SeniorCustomer.h"
#include <iostream>
// SeniorCustomer is a child class of CustomerEntity
// Constructor that initializes a SeniorCustomer with an ID and a specific position
SeniorCustomer::SeniorCustomer(std::string fID, Position position)
: CustomerEntity(fID, position, 20, 1500, 100, 20, 10) { // Call the parent class (CustomerEntity) constructor to initialize common attributes
circle.setFillColor(sf::Color::Blue); // Blue color
}
// Method to update the Customer's Ordering over time
void SeniorCustomer::update() {
// If the customer is seated and waiting for an appetizer
if (seated && !appetizerOrdered && !waitingForFood) {
// Start the timer for ordering after seating
if (seatedClock.getElapsedTime().asSeconds() >= 5) {
orderAppetizer();
}
}
// If the appetizer is received, now ask for the main course
if (appetizerOrdered && !mainCourseOrdered && !waitingForFood && assignedFood != nullptr) {
// Start asking for the main course after a delay
if (seatedClock.getElapsedTime().asSeconds() >= 5) {
orderMainCourse();
}
}
// Check if all courses are completed, mark the meal as finished and clear the table
if (appetizerOrdered && mainCourseOrdered && !waitingForFood && assignedFood != nullptr) {
chitChat(); // Call the chitChat() method
finishMeal(); // Call the method to handle finishing the meal
}
}
// Method to handle the assignment of Food to a Customer and to set appropriate messages
// based on the timing and correctness of the food served
void SeniorCustomer::assignFood(Food* food) {
if (food == nullptr) {
std::cerr << "Error: Null food pointer\n" << std::endl;
return;
}
float elapsedTime = foodClock.getElapsedTime().asSeconds();
bool servedOnTime = (elapsedTime <= 6); // the 6 second timer starts when the customer orders the food
// If served On Time && food served is Correct
if (servedOnTime && food->getFoodType() == expectedFoodType) {
fMessage = "IncreaseCurrentHappiness 50";
std::cout << "Customer " << fID << " received correct food within " << elapsedTime << " seconds.\n" << std::endl;
}
// If served Not On Time && food served is Correct
else if (!servedOnTime && food->getFoodType() == expectedFoodType) {
fMessage = "IncreaseCurrentHappiness 25";
std::cout << "Customer " << fID << " received correct food late after " << elapsedTime << " seconds.\n" << std::endl;
}
// If served On Time && food served is Incorrect
else if (servedOnTime && food->getFoodType() != expectedFoodType) {
fMessage = "DecreaseCurrentHappiness 50";
std::cout << "Customer " << fID << " received incorrect food within " << elapsedTime << " seconds.\n" << std::endl;
}
// If served Not On Time && food served is Incorrect
else if (!servedOnTime && food->getFoodType() != expectedFoodType) {
fMessage = "DecreaseCurrentHappiness 75";
std::cout << "Customer " << fID << " received incorrect food late after " << elapsedTime << " seconds.\n" << std::endl;
}
waitingForFood = false;
assignedFood = food; // Assign the food to the customer
seatedClock.restart();
}
// Method to have a chit-chat with the Player after finishing their meal
void SeniorCustomer::chitChat() {
char playerChoice;
// Start conversation
std::cout << "SeniorCustomer: \"Hope you don't mind a little chitchat. It's been a while since I've held a conversation with someone.\"\n";
// Loop until valid input is received
while (true) {
std::cout << "Player: Press 'A' to say \"Sure\" or 'B' to say \"Goodbye\"\n";
// Capture player's response
std::cin >> playerChoice;
// Handle the player's choice
if (playerChoice == 'A' || playerChoice == 'a') {
std::cout << "Player: \"Sure.\"\n";
std::cout << "SeniorCustomer: \"How long have you been working here?\"\n";
// Loop until valid input for the follow-up question
while (true) {
std::cout << "Player: Press 'A' to say \"Yesterday.\" or 'B' to say \"I wanna get fired...\"\n";
std::cin >> playerChoice;
if (playerChoice == 'A' || playerChoice == 'a') {
std::cout << "Player: \"Yesterday.\"\n";
std::cout << "SeniorCustomer: \"All the best! Starting a new job can be tough, but you'll get the hang of it.\"\n";
boostPlayerReputation();
break; // Exit the inner loop after valid input
}
else if (playerChoice == 'B' || playerChoice == 'b') {
std::cout << "Player: \"I wanna get fired...\"\n";
std::cout << "SeniorCustomer: \"Haha, tough day, huh? Well, hang in there, kid. All the best!\"\n";
boostPlayerReputation();
break; // Exit the inner loop after valid input
}
else {
std::cout << "Invalid choice! Please press 'A' or 'B'.\n";
}
}
break; // Exit the outer loop after handling the follow-up conversation
}
else if (playerChoice == 'B' || playerChoice == 'b') {
std::cout << "Player: \"Goodbye.\"\n";
std::cout << "SeniorCustomer: \"Okay, that's alright.\"\n";
break; // Exit the outer loop after valid input
}
else {
std::cout << "Invalid choice! Please press 'A' or 'B'.\n";
}
}
}
void SeniorCustomer::tip() {
// SeniorCustomer doesn't use this method
}
void SeniorCustomer::complain() {
// SeniorCustomer doesn't use this method
}