Coffee business transaction-based system,
#include <iostream>
#include <string>
using namespace std;
// Struct to hold customer information
struct Customer {
string name;
};
// Struct for Coffee Products
struct Coffee {
string name;
double prices[3]; // Prices for Small, Medium, and Venti
};
struct Pastry {
string name;
double price;
};
// Struct to hold transaction info
struct Transaction {
string customerName;
string product;
double price;
};
// CoffeeStore class to manage products and transactions
class CoffeeStore {
private:
Customer customers[10]; // Array to store up to 10 customers
int customerCount = 0; // Track number of customers
Transaction transactions[10]; // Array to store up to 10 transactions
int transactionCount = 0; // Track number of transactions
// Coffee products
Coffee icedCoffees[3] = {
{"Dark Mocha", {100, 120, 140}}, // Prices for Small, Medium, Venti
{"Spanish Latte", {110, 130, 150}},
{"Java Chip", {120, 140, 160}},
};
Coffee antiCoffees[3] = {
{"Cinnamon Latte", {100, 120, 140}},
{"Oreo Pan au Chocolat", {130, 150, 170}},
{"Strawberry and Creme", {120, 140, 160}},
};
Pastry pastries[3] = {
{"Dulce Ensaymada", 119},
{"Brownies", 129},
{"Blueberry Cheesecake", 219}
};
public:
// Function to add a customer to the list
void addCustomer() {
if (customerCount >= 10) {
cout << "Customer list is full.\n";
return;
}
string customerName;
cout << "Enter customer name: ";
cin.ignore(); // Clear any newline character from the buffer
getline(cin, customerName); // Add customer name
customers[customerCount] = {customerName}; // Add the customer to the array
customerCount++;
cout << "Customer " << customerName << " added successfully!" << endl;
}
// Function to show product categories
void displayCategories() {
cout << "Product Categories:\n";
cout << "1. Coffee's\n";
cout << "2. Collaboration Merchandise\n";
cout << "3. Brewed Awakening Accessories\n";
cout << "Select a category (1-3): ";
}
// Function to display coffee beverages
void displayCoffees() {
cout << "Coffee's:\n";
cout << "1. Iced Coffee\n";
cout << "2. Anti Coffee\n";
cout << "3. Pastries\n";
cout << "Select a coffee category to view (1-3): ";
int choice;
cin >> choice;
switch (choice) {
case 1:
cout << "Iced Coffee:\n";
for (int i = 0; i < 3; i++) {
cout << i + 1 << ". " << icedCoffees[i].name << endl;
}
break;
case 2:
cout << "Anti Coffee:\n";
for (int i = 0; i < 3; i++) {
cout << i + 1 << ". " << antiCoffees[i].name << endl;
}
break;
case 3:
cout << "Pastries:\n";
for (int i = 0; i < 3; i++) {
cout << i + 1 << ". " << pastries[i].name << " - Price: P" << pastries[i].price << endl;
}
break;
default:
cout << "Invalid category selected.\n";
return;
}
makeCoffeePurchase(choice);
}
void makeCoffeePurchase(int coffeeType) {
if (coffeeType == 1) { // Iced Coffee
cout << "Select an Iced Coffee (1-3): ";
int icedChoice;
cin >> icedChoice;
if (icedChoice < 1 || icedChoice > 3) {
cout << "Invalid choice.\n";
return;
}
cout << "Select size (1: Small, 2: Medium, 3: Venti): ";
int sizeChoice;
cin >> sizeChoice;
if (sizeChoice < 1 || sizeChoice > 3) {
cout << "Invalid size choice.\n";
return;
}
completeTransaction(icedCoffees[icedChoice - 1].name, icedCoffees[icedChoice - 1].prices[sizeChoice - 1]);
} else if (coffeeType == 2) { // Anti Coffee
cout << "Select an Anti Coffee (1-3): ";
int antiChoice;
cin >> antiChoice;
if (antiChoice < 1 || antiChoice > 3) {
cout << "Invalid choice.\n";
return;
}
cout << "Select size (1: Small, 2: Medium, 3: Venti): ";
int sizeChoice;
cin >> sizeChoice;
if (sizeChoice < 1 || sizeChoice > 3) {
cout << "Invalid size choice.\n";
return;
}
completeTransaction(antiCoffees[antiChoice - 1].name, antiCoffees[antiChoice - 1].prices[sizeChoice - 1]);
}
// No need for pastries in the coffee section purchase logic
}
// Function to complete the transaction
void completeTransaction(const string& product, double price) {
if (customerCount == 0) {
cout << "No customers available. Please add a customer first.\n";
return;
}
cout << "Select a customer to make the purchase (1-" << customerCount << "): ";
for (int i = 0; i < customerCount; i++) {
cout << i + 1 << ". " << customers[i].name << endl;
}
int customerChoice;
cin >> customerChoice;
if (customerChoice > 0 && customerChoice <= customerCount) {
string customerName = customers[customerChoice - 1].name;
if (transactionCount >= 10) {
cout << "Transaction history is full.\n";
return;
}
Transaction t = {customerName, product, price};
transactions[transactionCount] = t; // Add to transaction history
transactionCount++;
cout << customerName << " has purchased " << product << " for P" << price << endl;
} else {
cout << "Invalid customer selection.\n";
}
}
// Function to show transaction history
void displayTransactionHistory() {
cout << "\nTransaction History:\n";
if (transactionCount == 0) {
cout << "No transactions yet.\n";
return;
}
double total = 0.0; // Total cost
for (int i = 0; i < transactionCount; i++) {
cout << i + 1 << ". Customer: " << transactions[i].customerName
<< ", Product: " << transactions[i].product << " - P" << transactions[i].price << endl;
total += transactions[i].price; // Add to total
}
// Display total
cout << "Total Amount Spent: P" << total << endl;
}
};
int main() {
CoffeeStore store; // Create store object
int category;
while (true) {
cout << "\n--- Coffee Store Management ---" << endl;
cout << "1. Add Customer\n";
cout << "2. Display Categories\n";
cout << "3. View Transaction History\n";
cout << "4. Exit\n";
cout << "Select an option (1-4): ";
int choice;
cin >> choice;
switch (choice) {
case 1:
store.addCustomer(); // Add customer
break;
case 2:
store.displayCategories(); // Show categories
cin >> category;
if (category == 1) {
store.displayCoffees(); // Show coffee products
} else {
cout << "This category is not implemented yet.\n";
}
break;
case 3:
store.displayTransactionHistory(); // Show transaction history
break;
case 4:
cout << "Exiting the program...\n";
return 0; // Exit program
default:
cout << "Invalid choice, try again.\n";
}
}
return 0;
}