Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- //string name,string date,int phoneno, int time, int numberofpeople
- //insert, update, delete, view the reservation records
- using namespace std;
- const int NAME = 50;
- const int Month = 20;
- class Restaurant{
- struct ReserveNode{
- char Name[NAME];
- char MOfDate[Month];
- int date;
- int phoneno;
- int time;
- int numberofpeople;
- ReserveNode* next;
- ReservationNode(){
- date = 0;
- phoneno = 0;
- time = 0;
- numberofpeople = 0;
- }
- };ReserveNode* head;
- public:
- restaurant(){
- head = NULL;
- }
- void insert();
- void update();
- void deletereserve();
- void displayReservation();
- bool search(string name);
- };
- void Restaurant::insert(){
- ReserveNode* newNode, *nodein;
- newNode = new ReserveNode;
- cout << "Enter Customer name";
- cout << "(Maximum 50 word): ";
- cin.ignore();
- cin.getline(newNode->Name, NAME);
- cout << "Enter Month(Etc April):";
- cin.ignore();
- cin.getline(newNode->MOfDate, toupper(Month));
- cout << "Please enter the date:";
- cin >> newNode->date;
- cout << "Please enter time: ";
- cin >> newNode->time;
- cout << "Please enter Phone Number: ";
- cin >> newNode->phoneno;
- cout << "Please enter number of people: ";
- cin >> newNode->numberofpeople;
- if (!head)
- head = newNode;
- else
- {
- nodein = head;
- while (nodein->next != NULL){
- nodein = nodein->next;
- }
- nodein->next = newNode;
- }
- system("cls");
- }
- void Restaurant::displayReservation()
- {
- ReserveNode* nodein;
- nodein = head;
- if (nodein != NULL)
- {
- cout << "------------------------------------------\n";
- cout << " Restaurant Reservation Info \n";
- cout << "------------------------------------------\n";
- while (nodein)
- {
- cout << "Name: " << nodein->Name << endl;
- cout << "Date: " << nodein->MOfDate << " "<< nodein->date << endl;
- cout << "Time: " << nodein->time << endl;
- cout << "Phone No: " << nodein->phoneno << endl;
- cout << "Number of People: " << nodein->numberofpeople << endl;
- nodein = nodein->next;
- }
- }
- else
- cout << "Empty List. Please Enter Reservation Information..\n";
- }
- bool Restaurant::search(string name)
- {
- ReserveNode *nodein;
- nodein = head;
- bool found;
- found = false;
- while ((nodein != NULL) && (!found))
- {
- if (nodein->Name == name)
- found = true;
- else
- nodein = nodein->next;
- }
- return found;
- }
- int main()
- {
- string name;
- Restaurant list;
- int decision;
- char loop = 'y';
- do
- {
- cout << "-------------------------------------------\n";
- cout << " RESERVATION SYSTEM \n";
- cout << "-------------------------------------------\n";
- cout << "Press (1) to Enter customer information " << endl;
- cout << "Press (2) to Display all customer information " << endl;
- cout << "Press (3) to Search Customer " << endl;
- cout << "Press (4) to Quit the program" << endl;
- cin >> decision;
- if (decision == 1){
- list.insert();
- }
- else if(decision == 2){
- list.displayReservation();
- cout << endl;
- }
- else if (decision == 3){
- cout << "Enter name of customer that you want to search: " << endl
- << "Name: ";
- cin.ignore(80, '\n');
- getline(cin, name);
- if (list.search(name))
- cout << name << "is found.";
- else
- cout << "Unknown. name not found";
- }
- else if ( decision == 4){
- loop = 'n';
- cout << "\nExiting the program..\n";
- }
- else{
- cout << "this is an invalid choice. Please select prompt from the menu.\n";
- system("pause");
- }
- } while ((loop == 'Y') || (loop == 'y'));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement