Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CS211 - Assignment 2 In this assignment, you need to write a program that allows users to make daily dinner reservations at local restaurants. The

CS211 - Assignment 2

In this assignment, you need to write a program that allows users to make daily dinner reservations at local restaurants. The program simulates online restaurant reservations systems. This involves designing three classes: RestaurantReservations, Restaurant, andReservation. All class attributes must be private and accessed through public member functions.

The attributes of each class are summarized below:

- RestaurantReservations class has the following private attribute:

vector restaurants; // list of local restaurants

- Restaurant class has the following private attributes:

string restaurantName; // restaurant name

string restaurantAddress; // restaurant address

string restaurantCity; //restaurant city

string restaurantType; // type of food served at restaurant

int availableSeats [4]; // array holding number of available seats at 4 possible times: 5, 6, 7, and 8 PM

vector reservations; // list of reservations at this restaurant

- Reservation class has the following private attributes:

const long reservationNum; // reservation number which is set to the value of nextReservationNum

string contactName; // name of person making reservation

string contactPhone; // persons phone number

int groupSize; // number of persons in reservation

int reservationTime; //reservation time which could be 5, 6, 7, or 8 pm

static long nextReservationNum; //initialize it to 100 and increment it by 10 as you create a new Reservation object

For each class, you need to write an appropriate constructor, accessor and mutator functionsas needed. The member functions for the RestaurantReservations class are summarized below:

- void RestaurantReservations::ProcessTransactionFile(string fileName) This function opens the transaction file, named fileName and processes its lines one by one. Each line contains a specific command along with its required data. The commands and their formats are:

CreateNewRestaurant rName rAddress rCity rType rCapacity

FindTable rCity rType rGroup rTime

FindTableAtRestaurant rName rGroup

MakeReservation rName cName cPhone rGroup rTime

CancelReservation rName rNum

PrintAllRestaurants

PrintRestaurantReservations rName

A sample transaction file is shown later. If the file could not be opened, you should print an appropriate error message.

- void RestaurantReservations::CreateNewRestaurant ( string rName, string rAddress, string rCity, string rType, int rCapacity)

This function creates a new Restaurant object by calling the appropriate constructor and adds it to the restaurants vector. The reservations vector is initially empty and is updated later in the makeReservation method. The array availableSeatsselements are all set to the value of rCapacity. The remaining restaurant attributes are set to the argument values rName, rAddress, rCity, and rType.

- void RestaurantReservations::PrintAllRestaurants() This function prints summary information of all restaurants in the restaurants vector. You should print the restaurant name, address, type, and capacity in a neat table format. For example:

Restaurant Address, City Type Capacity

---------------------------------------------------------------------------------------------------------------

LaPizzeria 4365NobleDr, SanDiego italian 20 ...

- void RestaurantReservations::FindTable(string rCity, string rType, int rGroup, int rTime)

This function searches for all restaurants in a specific city, rCity, of a specific type,rType, and having at a specific time, rTime, enough seats for a given group of people, rGroup. If such restaurants are found, the function prints the names of all such restaurants. For example:

 FindTable SanDiego italian 10 5 You may reserve a table for 10 at 5 pm at: LaPizzeria Civico 

Otherwise, it prints an appropriate error message.

FindTable SanDiego italian 10 5 No restaurant can accommodate such a group at this time, check another time

-void RestaurantReservations::FindTableAtRestaurant (string rName, int rGroup)

This function finds all possible availabilities for a given group of people, rGroup, at a specific restaurant whose name is rName. In other words, it prints the possible times at which such a group can reserve a table at this restaurant. For example:

FindTableAtRestaurant LaPizzeria 2 You can reserve a table for 2 at LaPizzeria at 7:00 pm, 8:00 pm 

If the restaurant name is invalid or the restaurant can not accommodate such a group at any time, this function prints an appropriate error message.

 FindTableAtRestaurant LaPizzeria 8 LaPizzeria does not have such availability 

- void RestaurantReservations::MakeReservation (string rName, string cName, string cPhone, int rGroup, int rTime ) This function creates a new Reservation object and adds it to the reservations vector of the restaurant whose name is rName. You can use the push_back function to add the new object at then of the vector. The customer name, phone, group and time should be set to cName, cPhone, rGroup, andrTimerespectively. reservationNum for the new object should be set to the value of nextReservationNum and then nextReservationNum should be incremented by 10. The function also updates the available seats array at that specific time. Note that the first array element corresponds to the available seats at 5:00 pm. The second corresponds to the availabilities at 6:00 pm and so on.

- void RestaurantReservations::CancelReservation (string rName, long rNum)

This function deletes a reservation whose number is rNum from the reservationsvector of the restaurant whose name is rName. It also updates, for that restaurant, the available seats entry at that time.

- void RestaurantReservations::PrintRestaurantReservations (string rName) This function prints the details of all reservations at the restaurant whose name isrName. Details include the following information: reservation number, customer name, phone number, group size and reservation time. For example:

PrintRestaurantReservations Barrio 

Reservation Contact Phone Group Time

----------------------------------------------------------------------------

170 Jenna 633-782-9848 4 8:00 PM

180 Davina 315-380-9848 20 7:00 PM

190 Pete 215-380-9845 6 7:00 PM

Note: Any member function that does not modify the attributes must be made constant.

After designing your classes (and breaking up your classes into .cpp and .h files), write a main program that instantiates an object of type RestaurantReservations and calls a method to read a transaction file and process its commands. Your main should look like this:

int main()

{

RestaurantReservations openTable;

openTable.ProcessTransactionFile("TransactionFile.txt");

return 0;

}

- Then test your code by including the following commands in your transaction file:

CreateNewRestaurant LaPizzeria 4356NobelDr SanDiego italian 10 CreateNewRestaurant Civico 8765RegentsRd SanDiego italian 20 CreateNewRestaurant OnBorder 101DoveSt SanDiego mexican 20 CreateNewRestaurant Ortega 3465RegentsRd SanDiego mexican 30 CreateNewRestaurant OlivioRistorante 4320CaminoDr Carlsbad italian 15 CreateNewRestaurant MariaRistorante 6534SpringburstDr Carlsbad italian 10 CreateNewRestaurant Agave 8764CreekViewBlvd Carlsbad mexican 30 CreateNewRestaurant Barrio 5Broadway Carlsbad mexican 30 PrintAllRestaurants 
FindTable SanDiego italian 10 5 MakeReservation LaPizzeria John 858-334-3334 10 5 FindTable SanDiego italian 15 5 MakeReservation Civico Jamie 316-324-1234 15 5 FindTable SanDiego italian 10 5 FindTable SanDiego italian 10 6 MakeReservation LaPizzeria Andrea 513-984-7878 10 6 FindTable SanDiego italian 5 7 MakeReservation LaPizzeria Amy 838-234-3111 5 7 FindTable SanDiego mexican 10 8 MakeReservation OnBorder Bill 222-532-3148 10 8 FindTable SanDiego mexican 10 8 MakeReservation OnBorder Andre 325-632-9148 10 8 FindTable SanDiego mexican 2 8 MakeReservation Ortega Kathy 617-682-5148 2 8 FindTable Carlsbad mexican 4 8 MakeReservation Barrio Jenna 633-782-9848 4 8 FindTable Carlsbad mexican 20 7 MakeReservation Barrio Davina 315-380-9848 20 7 MakeReservation Barrio Pete 215-380-9845 6 7 FindTable Carlsbad mexican 5 7 MakeReservation Agave Joe 399-300-1848 5 7 FindTable Carlsbad italian 5 6 MakeReservation OlivioRistorante Courtney 229-456-1865 5 6 MakeReservation OlivioRistorante Patrick 665-102-0876 5 6 MakeReservation MariaRistorante Nancy 218-396-2349 5 6 FindTableAtRestaurant LaPizzeria 2 MakeReservation LaPizzeria Carolyn 613-084-7898 2 7 FindTableAtRestaurant LaPizzeria 3 MakeReservation LaPizzeria Edward 313-284-0087 3 7 FindTableAtRestaurant LaPizzeria 3 MakeReservation LaPizzeria Michael 215-487-1082 3 8 FindTableAtRestaurant Agave 26 MakeReservation Agave Joe 615-233-1065 26 5 FindTableAtRestaurant LaPizzeria 8 CancelReservation LaPizzeria 260 CancelReservation LaPizzeria 250 FindTableAtRestaurant LaPizzeria 8 MakeReservation LaPizzeria Ellen 867-580-2047 8 8
CancelReservation Civico 110 FindTableAtRestaurant Civico 20 MakeReservation Civico Jared 337-324-2047 20 5 PrintRestaurantReservations LaPizzeria PrintRestaurantReservations Civico PrintRestaurantReservations Ortega PrintRestaurantReservations OlivioRistorante PrintRestaurantReservations Agave PrintRestaurantReservations Barrio PrintRestaurantReservations Season23

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions

Question

Create a workflow analysis.

Answered: 1 week ago