Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef HEADER_H
- #define HEADER_H
- #include <string>
- #include <iostream>
- #include <iomanip>
- using namespace std;
- class CreditCard
- {
- string cCard;
- int pin;
- double balance;
- public:
- CreditCard()
- {
- string creditC = "";
- int pinNum = 0;
- double balanceCC = 0;
- }
- CreditCard(string creditC, int pinNum, double balanceCC)
- {
- cCard = creditC;
- pin = pinNum;
- balance = balanceCC;
- }
- void SetCCard(string creditC)
- {
- cCard = creditC;
- }
- void SetPin(int pinNum)
- {
- pin = pinNum;
- }
- void SetBalance(double balanceCC)
- {
- balance = balanceCC;
- }
- string GetCCard()
- {
- return cCard;
- }
- int GetPin()
- {
- return pin;
- }
- double GetBalance()
- {
- return balance;
- }
- ~CreditCard()
- {}
- };
- class Human
- {
- string firstName;
- string lastName;
- string address;
- string city;
- string state;
- int zipCode;
- string id;
- string password;
- CreditCard creditCard;
- public:
- Human()
- {
- string fn = "";
- string ln = "";
- string add = "";
- string c = "";
- string st = "";
- int zip = 0;
- string tempId = "";
- string pass = "";
- }
- Human(string fn, string ln, string add, string c, string st, int zip, string tempId, string pass)
- {
- firstName = fn;
- lastName = ln;
- address = add;
- city = c;
- state = st;
- zipCode = zip;
- id = tempId;
- password = pass;
- }
- void SetFirstName(string fn)
- {
- firstName = fn;
- }
- void SetLastName(string ln)
- {
- lastName = ln;
- }
- void SetAddress(string add)
- {
- address = add;
- }
- void SetCity(string c)
- {
- city = c;
- }
- void SetState(string st)
- {
- state = st;
- }
- void SetZipCode(int zip)
- {
- zipCode = zip;
- }
- void SetId(string tempId)
- {
- id = tempId;
- }
- void SetPassword(string pass)
- {
- password = pass;
- }
- string GetFirstName()
- {
- return firstName;
- }
- string GetLastName()
- {
- return lastName;
- }
- string GetAddress()
- {
- return address;
- }
- string GetCity()
- {
- return city;
- }
- string GetState()
- {
- return state;
- }
- int GetZipCode()
- {
- return zipCode;
- }
- string GetId()
- {
- return id;
- }
- string GetPassword()
- {
- return password;
- }
- void SetCreditCard(string cCard, int pin, double balance)
- {
- creditCard.SetCCard(cCard);
- creditCard.SetPin(pin);
- creditCard.SetBalance(balance);
- }
- string GetCCard()
- {
- return creditCard.GetCCard();
- }
- int GetPin()
- {
- return creditCard.GetPin();
- }
- double GetBalance()
- {
- return creditCard.GetBalance();
- }
- virtual void Talk()
- {
- }
- ~Human()
- {}
- };
- //abstract customer class
- class Customer : public Human
- {
- public:
- Customer()
- {
- string fn = "";
- string ln = "";
- string add = "";
- string c = "";
- string st = "";
- int zip = 0;
- }
- Customer(string fn, string ln, string add, string c, string st, int zip)
- {
- }
- ~Customer()
- {}
- };
- //abstract Matre'd class
- class MatreD : public Human
- {
- Customer *customerDB;
- int customerIndex;
- int i;
- public:
- MatreD()
- {}
- void SetCustomerDB(Customer *db)
- {
- customerDB = db;
- }
- void SetCustomerIndex()
- {
- customerIndex = i;
- }
- int GetCustomerIndex()
- {
- return customerIndex;
- }
- void Talk()
- {
- string userFirst, userLast;
- cout << "Welcome to Gooms' Reastaurant, my name is " << GetFirstName() << " " << GetLastName() << "." << endl;
- cout << "Before I can seat you, I must verify that you are in our database." << endl;
- //do-while loop to check if name entered by user is in the database
- bool foundName = false;
- do
- {
- cout << "May I please have your first name? ";
- cin >> userFirst;
- cout << "May I please have your last name? ";
- cin >> userLast;
- // Lookup name
- for(int i = 0; i < 10000; i++)
- {
- if(userFirst == customerDB[i].GetFirstName() && userLast == customerDB[i].GetLastName())
- {
- foundName = true;
- customerIndex = i;
- break;
- }
- }
- }while(foundName == false);
- }
- ~MatreD()
- {}
- };
- //Menu class
- class MenuItem
- {
- string itemName;
- string itemDescription;
- double itemPrice;
- int qtyPurchased;
- public:
- MenuItem()
- {
- itemName = "";
- itemDescription = "";
- itemPrice = 0;
- qtyPurchased = 0;
- }
- MenuItem(string name, string desc, double price)
- {
- itemName = name;
- itemDescription = desc;
- itemPrice = price;
- qtyPurchased = 0;
- }
- void SetItemName(string name)
- {
- itemName = name;
- }
- void SetItemDescription(string desc)
- {
- itemDescription = desc;
- }
- void SetItemPrice(double price)
- {
- itemPrice = price;
- }
- void SetQtyPurchased(int qty)
- {
- qtyPurchased = qty;
- }
- string GetItemName()
- {
- return itemName;
- }
- string GetItemDescription()
- {
- return itemDescription;
- }
- double GetItemPrice()
- {
- return itemPrice;
- }
- int GetQtyPurchased()
- {
- return qtyPurchased;
- }
- };
- //abstrast Server class
- class Server : public Human
- {
- Customer *customerDB;
- int customerIndex;
- MenuItem *menuDB;
- public:
- Server()
- {}
- void SetCustomerDB(Customer *cust)
- {
- customerDB = cust;
- }
- void SetCustomerIndex(int i)
- {
- customerIndex = i;
- }
- void SetMenuDB(MenuItem *menu)
- {
- menuDB = menu;
- }
- double ComputeTotal()
- {
- double runningTotal = 0;
- for(int j = 0; j < 10; j++)
- {
- runningTotal += menuDB[j].GetItemPrice() * menuDB[j].GetQtyPurchased();
- }
- return runningTotal * 1.10 * 1.20;
- }
- //prints the customer info
- void PrintCustomerInfo()
- {
- cout << "************************" << endl;
- cout << " Customer Information " << endl;
- cout << "************************" << endl;
- cout << customerDB[customerIndex].GetFirstName() << " ";
- cout << customerDB[customerIndex].GetLastName() << endl;
- cout << customerDB[customerIndex].GetAddress() << endl;
- cout << customerDB[customerIndex].GetCity() << ", ";
- cout << customerDB[customerIndex].GetState() << " ";
- cout << customerDB[customerIndex].GetZipCode() << endl;
- }
- //prints the menu for ordering
- void PrintMenu()
- {
- cout << "Gooms' Restaurant Menu" << endl;
- cout << "----------------------" << endl;
- for(int k = 0; k < 10; k++)
- {
- cout << k << ". " << menuDB[k].GetItemName() << " $" << menuDB[k].GetItemPrice() << " " <<menuDB[k].GetItemDescription() << endl;
- }
- }
- void Talk()
- {
- //Greet customer and get ready to verify info
- string custFirstName = customerDB[customerIndex].GetFirstName();
- string custLastName = customerDB[customerIndex].GetLastName();
- cout << "Hello " << custFirstName << " " << custLastName << endl;
- cout << "My name is " << GetFirstName() << " " << GetLastName() << "." << endl;
- cout << "I have a few questions for you to verify your information in our database." << endl;
- //verifies the customers id number
- string tempId;
- bool isCorrect;
- do
- {
- cout << "What is your id number?" << endl;
- cin >> tempId;
- isCorrect = (tempId == customerDB[customerIndex].GetId());
- if(isCorrect == false)
- {
- cout << "The id number entered doesn't match our records, please enter your id again." << endl;
- }
- }while(!isCorrect);
- //verifies the customers password
- string tempPassword;
- do
- {
- cout << "What is your password?" << endl;
- cin >> tempPassword;
- isCorrect = (tempPassword == customerDB[customerIndex].GetPassword());
- if(isCorrect == false)
- {
- cout << "The password entered doesn't match our records, please enter your password again." << endl;
- }
- }while(!isCorrect);
- //verifies the customers credit card number
- string tempCCard;
- do
- {
- cout << "What is your credit card number?" << endl;
- cin >> tempCCard;
- isCorrect = (tempCCard == customerDB[customerIndex].GetCCard());
- if(isCorrect == false)
- {
- cout << "The credit card number entered doesn't match our records, please enter your credit card again." << endl;
- }
- }while(!isCorrect);
- //verifies the customers pin number
- int tempPin;
- do
- {
- cout << "What is your pin number?" << endl;
- cin >> tempPin;
- isCorrect = (tempPin == customerDB[customerIndex].GetPin());
- if(isCorrect == false)
- {
- cout << "The pin number entered doesn't match our records, please enter your pin again." << endl;
- }
- }while(!isCorrect);
- //info verified and print the main customer info for them to see
- cout << "Thank you your information has been verified by our database." << endl;
- //print customer info after verifying
- PrintCustomerInfo();
- char response;
- while(true)
- {
- // Get user order
- cout << endl;
- cout << "Here is our Menu, please make a selection between 0 and 9 or press Q to quit." << endl;
- PrintMenu();
- cin >> response;
- cin.ignore(100,'\n');
- // Quit if requested
- if(toupper(response) == 'Q')
- break;
- // Convert response to integer and verify it's valid
- int itemNumber = response - '0';
- if(itemNumber < 0 || itemNumber > 9)
- {
- cout << "Invalid selection" << endl;
- continue;
- }
- // Add the item
- menuDB[itemNumber].SetQtyPurchased(menuDB[itemNumber].GetQtyPurchased() + 1);
- if(ComputeTotal() > customerDB[customerIndex].GetBalance())
- {
- menuDB[itemNumber].SetQtyPurchased(menuDB[itemNumber].GetQtyPurchased() - 1);
- cout << "Not enought money on your credit card balance." << endl;
- }
- };
- //prints the total price of their meal and thanks them for coming
- cout << endl;
- PrintCustomerInfo();
- cout.setf(ios::fixed);
- cout << "Your total with 10% tax and 20% gratuity is " << "$" << setprecision(2) << ComputeTotal() << endl;
- double finalBalance;
- finalBalance = customerDB[customerIndex].GetBalance() - ComputeTotal();
- cout << "Your remaining balance on your Credit Card is $" << setprecision(2) << finalBalance << endl;
- //customerDB[customerIndex].SetCreditCard = finalBalance;
- cout << "Thank you for visiting Gooms' Restaurant, please come again." << endl;
- // Reset MenuDB Qty Purchased
- for(int i = 0; i < 10; i++)
- {
- menuDB[i].SetQtyPurchased(0);
- }
- }//end of talk function
- {}
- };
- #endIf;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement