Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This assignment mimics the configuration and activities happen at a typical rest

ID: 3552890 • Letter: T

Question

This assignment mimics the configuration and activities happen at a typical restaurant. Input is provided in 2 files: config.txt and activity.txt. Configuration file contains how many tables, table - waiter relationship & full menu list. Activity file mimics the actual activities that happen in restaurant. After setting up the necessary objects using the configuration file, you can read the activity file and process them. Then, you should be able to answer various queries. You should not use vector or any other template in this assignment.

We will use the following classes to complete this assignment. Feel free to add more variables if needed. Avoid making drastic changes to existing variables. You need to implement all the .cpp files including class implementation and overall application functionality.

Table : status, # of max seats, # of guests, order, waiter

menu_item: item_code, name, price

Menu : list of menu items

Order : a list of menu items ordered at a table

Payment: table #, # of guests, waiter, order, total

configuration file (config.txt)
(this is how the file will look)

Tables: table #, max seats

1 2

2 4

3 2

4 2

5 2

6 4

7 6

8 10

9 2

10 4

11 4

12 4

13 4

14 2

15 2

16 2

17 2

18 2

Waiters: first name followed by table list

John 1,2,5,9,11,15

Maria 3,4,6,7,17,18

Mike 8,10,12,13,14,26

Menu: listing of the full menu: item code, name, price

A1 Bruschetta 5.29

A2 Caprese_Flatbread 6.10

A3 Artichoke-Spinach_Dip 3.99

A4 Lasagna_Fritta 4.99

A5 Mozzarella_Fonduta 5.99

E1 Lasagna_Classico 6.99

E2 Capellini_Pomodoro 7.99

E3 Eggplant_Parmigiana 8.99

E4 Fettuccine_Alfredo 7.49

E5 Tour_of_Italy 14.99

D1 Tiramisu 2.99

D2 Zeppoli 2.49

D3 Dolcini 3.49

S1 Soda 1.99

S2 Bella_Limonata 0.99

S3 Berry_Acqua_Fresca 2.88

Sample activity file (comments are not part of the file):

T1 P2 // Party of 2 is assigned to Table 1

T2 P4

T4 P2

T1 O A1 A1 E1 E2 // Party at table 1 orders these items

T8 P10

T1 S // Food arrives at table 1

T3 P2

T1 C // T1 gets the check, pays and leaves & table is cleaned too.

T5 P2

T1 P1 // Party of 1 is assigned to table 1

...

In addition to processing these commands, when a table is closed, display the check as well. Include table #, # of customers in the party, name and price of each ordered item and the total. No need to worry about tax or tips.

Error checking:

- Do not allow orders from table with no party assigned to it.

- Do not allow assigning new party to a table when another party is already there.

- Do not allow assigning new party to a table for which waiter has not been assigned.

- Do not allow check-out from empty table.

- Do not allow delivery of food to an empty table!

- Do not assign any party to table with no waiter assignment.

- Reject any request that does not match with sample formats.

Unlike Java, there is no bult-in String Tokenizer in C++. I have attached a zip archive that Tokenizer functionality. This can be helpful to read and process the input lines from the files.

everything from here is code given. ill put a comment with the program name at the beginning so you where a new one starts if something doesnt work make a comment i will be checking this alot today it is due tonight.
(note if you can help me figure out how to do the work myself ill give helpful. if you do the program or give me great help on how to do it myself i will give lifesaver. i am just not sure on how to do this assignment currently)



//Menu.h

#ifndef MENU_H
#define MENU_H
#include "MenuItem.h"

class Menu
{
private:
int maxItems; // MAX capacity
int numItems; // current # of items in menu
MenuItem *menup;

public:

Menu(int items = 100); //constructor to allocate memory
void addItem(MenuItem item); //add one menu item at a time
MenuItem *findItem(string code); //lookup operation
~Menu(); //destructor
};
#endif





//MenuItem.h

#ifndef MENUITEM_H
#define MENUITEM_H
#include
#include

using namespace std;

class MenuItem
{
private:
string code; // See sample codes in config.txt
string name; // Full name of the entry
double price; // price of the item

public:
MenuItem(string mcode = "", string mname= "", double mprice = 0);
};
#endif





//Order.h

#ifndef ORDER_H
#define ORDER_H

#include "MenuItem.h"
#include "Menu.h"

class Order
{
private:
int maxItems; // # of items in the order
int numItems; // current # of items in the order
MenuItem **itemsp;

public:
Order(int count); //allocates array of pointers to "selected" menu items
int addItem(MenuItem *itemp); // add one item at a time to the order

Order(string orderList, Menu *menu); // alternate way to setup the order

~Order();
};
#endif





// Payment.h

#ifndef PAYMENT_H
#define PAYMENT_H
#include "Order.h"
#include "Menu.h"
#include "Waiter.h"

class Payment
{
private:
int tableId; // table number
int numPeople; // number of people in the party
Order *orderp; // order information
double total; // total bill
Waiter *waiterp; // pointer to waiter

public:
Payment();
Payment(int tblId, npersons, order, total, waiter);
};
#endif





//Table.h


#ifndef TABLE_H
#define TABLE_H
#include "Order.h"
#include "Waiter.h"

enum TableStatus { IDLE, SEATED, ORDERED, SERVED };

class Waiter; // to take care of circular reference.

class Table
{
private:
int tableId; // table number
const int maxSeats; // table seat capacity
TableStatus status; // current status, you can use assign like
// status = IDLE;
int numPeople; // number of people in current party
Order *order; // current party's order
Waiter *waiter; // pointer to waiter for this table

public:
Table(int tblid =0, int mseats = 0); // initialization, IDLE
void assignWaiter(Waiter *person); // initially no waiter
void partySeated(int npeople); // process IDLE --> SEATED
void partyOrdered(Order *order); // process SEATED --> ORDERED
void partyServed(void); // process ORDERED --> SERVED
void partyCheckout(void); // process SERVED --> IDLE
};
#endif







//Waiter.h

#ifndef WAITER_H
#define WAITER_H
#include
#include "Table.h"

class Table; // to take care of circular reference.

class Waiter
{
private:
string name; // waiter's name
int numTables; // number of tables waiter is in-charge for
Table **tables; // waiter's table list

public:
~Waiter();
Waiter(string name = "", string TableList = "", Table *table = NULL);
// waiter's name, his table list as a string, table array pointer
};

#endif







//test.cpp (tests the tokenizer/ shows how it works)


#include
#include
#include
#include
#include "Tokenizer.h"

using namespace std;

int main()
{

double x, y, z;

while (1) {
string line;

x = y = z = -1;
cout << "Enter input (3 numbers):";
getline(cin, line);

// parse the input line
istringstream input(line);
if (input >> x >> y >> z)
cout << "input is good." << endl;
else
cout << "input read error." << endl;
cout << x << " " << y << " " << z << endl;
// tokenizing example
Tokenizer str(line);
str.setDelimiter(" ,");
// Tokenizer str(line, " ,");
string token;
while ((token = str.next()) != "")
cout << token << endl;

// identifying empty lines
Tokenizer str2(line);
str2.setDelimiter(" ");
if (str2.next() == "")
cout << "That was empty line." << endl;

}
}








//Tokenizer.cpp

///////////////////////////////////////////////////////////////////////////////
// Tokenizer.cpp
// =============
// General purpose string tokenizer (C++ string version)
//
// The default delimiters are space(" "), tab( , ), newline( ),
// carriage return( ), and form feed( ).
// If you want to use different delimiters, then use setDelimiter() to override
// the delimiters. Note that the delimiter string can hold multiple characters.
//
// AUTHOR: Song Ho Ahn
// CREATED: 2005-05-25
// UPDATED: 2008-01-22
///////////////////////////////////////////////////////////////////////////////

#include "Tokenizer.h"


///////////////////////////////////////////////////////////////////////////////
// constructor
///////////////////////////////////////////////////////////////////////////////
Tokenizer::Tokenizer() : buffer(""), token(""), delimiter(DEFAULT_DELIMITER)
{
currPos = buffer.begin();
}

Tokenizer::Tokenizer(const std::string& str, const std::string& delimiter) : buffer(str), token(""), delimiter(delimiter)
{
currPos = buffer.begin();
}



///////////////////////////////////////////////////////////////////////////////
// destructor
///////////////////////////////////////////////////////////////////////////////
Tokenizer::~Tokenizer()
{
}



///////////////////////////////////////////////////////////////////////////////
// reset string buffer, delimiter and the currsor position
///////////////////////////////////////////////////////////////////////////////
void Tokenizer::set(const std::string& str, const std::string& delimiter)
{
this->buffer = str;
this->delimiter = delimiter;
this->currPos = buffer.begin();
}

void Tokenizer::setString(const std::string& str)
{
this->buffer = str;
this->currPos = buffer.begin();
}

void Tokenizer::setDelimiter(const std::string& delimiter)
{
this->delimiter = delimiter;
this->currPos = buffer.begin();
}



///////////////////////////////////////////////////////////////////////////////
// return the next token
// If cannot find a token anymore, return "".
///////////////////////////////////////////////////////////////////////////////
std::string Tokenizer::next()
{
if(buffer.size() <= 0) return ""; // skip if buffer is empty

token.clear(); // reset token string

this->skipDelimiter(); // skip leading delimiters

// append each char to token string until it meets delimiter
while(currPos != buffer.end() && !isDelimiter(*currPos))
{
token += *currPos;
++currPos;
}
return token;
}



///////////////////////////////////////////////////////////////////////////////
// skip ang leading delimiters
///////////////////////////////////////////////////////////////////////////////
void Tokenizer::skipDelimiter()
{
while(currPos != buffer.end() && isDelimiter(*currPos))
++currPos;
}



///////////////////////////////////////////////////////////////////////////////
// return true if the current character is delimiter
///////////////////////////////////////////////////////////////////////////////
bool Tokenizer::isDelimiter(char c)
{
return (delimiter.find(c) != std::string::npos);
}





//Tokenizer.h

///////////////////////////////////////////////////////////////////////////////
// Tokenizer.h
// ===========
// General purpose string tokenizer (C++ string version)
//
// The default delimiters are space(" "), tab( , ), newline( ),
// carriage return( ), and form feed( ).
// If you want to use different delimiters, then use setDelimiter() to override
// the delimiters. Note that the delimiter string can hold multiple characters.
//
// AUTHOR: Song Ho Ahn
// CREATED: 2005-05-25
// UPDATED: 2006-05-18
///////////////////////////////////////////////////////////////////////////////

#ifndef TOKENIZER_H
#define TOKENIZER_H

#include

// default delimiter string (space, tab, newline, carriage return, form feed)
const std::string DEFAULT_DELIMITER = " ";

class Tokenizer
{
public:
// ctor/dtor
Tokenizer();
Tokenizer(const std::string& str, const std::string& delimiter=DEFAULT_DELIMITER);
~Tokenizer();

// set string and delimiter
void set(const std::string& str, const std::string& delimiter=DEFAULT_DELIMITER);
void setString(const std::string& str); // set source string only
void setDelimiter(const std::string& delimiter); // set delimiter string only

std::string next(); // return the next token, return "" if it ends


protected:


private:
void skipDelimiter(); // ignore leading delimiters
bool isDelimiter(char c); // check if the current char is delimiter

std::string buffer; // input string
std::string token; // output string
std::string delimiter; // delimiter string
std::string::const_iterator currPos; // string iterator pointing the current position

};

#endif // TOKENIZER_H

Explanation / Answer

Can you please give me the points? I really need them. I will return the favor ;)