In this workshop, you will code three classes that are in composition and aggregation relations. The classes will simulate a very simplified form of managing reservations in a restaurant. The restaurant will manage a collection of reservations (composition); a messaging system will be used to send confirmations for the reservation.
Upon successful completion of this workshop, you will have demonstrated the abilities to:
The in-lab portion of this workshop consists of modules:
Enclose all your source code within the sdds namespace and include the necessary guards in each header file.
w4 Module (supplied)
Do not modify this module! Look at the code and make sure you understand it.
Reservation Module
This module defines a class that holds information about a single reservation at a restaurant for a date/time in October.
Design and code a class named Reservation that should be able to store the following information (for each attribute, you can chose any type you think it's appropriate--you must be able to justify the decisions you have made):
Public Members
ID:NAME,EMAIL,PARTY SIZE,DAY,HOUR
This constructor should remove all spaces from the beginning and end of any token in the string.
When implementing the constructor, consider the following functions:
Friend Helpers
overload the insertion operator to insert the content of a reservation object into an ostream object:
if the hour is between 6AM and 9AM (inclusive), the kitchen serves breakfast:
Reservation ID: NAME < email> Breakfast on day DAY @ HOUR:00 for #PARTY_SIZE people.
if the hour is between 11AM and 3PM (inclusive), the kitchen serves lunch:
Reservation ID: NAME < email> Lunch on day DAY @ HOUR:00 for #PARTY_SIZE people.
if the hour is between 5PM and 9PM (inclusive), the kitchen serves dinner:
Reservation ID: NAME < email> Dinner on day DAY @ HOUR:00 for #PARTY_SIZE people.
at any other time the kitchen is closed and only drinks can be served:
Reservation ID: NAME < email> Drinks on day DAY @ HOUR:00 for #PARTY_SIZE people.
the name on the reservation should be printed on a field of size 10, aligned to the right
the email on the reservation (including the characters < and >) should be printed on a field of size 20, aligned to the left.
this operator should insert the endline character before exiting.
Sample Output
When the program is started with the command (the file data.txt is provided):
w4.exe data.txt
the output should look like:
Command Line:
--------------------------
1: w4.exe
2: data.txt
--------------------------
Reservations
--------------------------
Reservation RES-001: John < john@email.com> Drinks on day 3 @ 5:00 for 2 people.
Reservation RES-002: David < david@email.com> Breakfast on day 4 @ 6:00 for 1 people.
Reservation RES-003: Sara < sara@email.com> Breakfast on day 5 @ 7:00 for 2 people.
Reservation RES-004: Ana < ana@email.com> Breakfast on day 5 @ 8:00 for 1 people.
Reservation RES-005: John < john@email.com> Breakfast on day 4 @ 9:00 for 1 people.
Reservation RES-006: Vanessa < vanessa@email.com> Drinks on day 3 @ 10:00 for 2 people.
Reservation RES-007: Mike < mike@email.com> Lunch on day 4 @ 11:00 for 4 people.
Reservation RES-008: Mike < mike@email.com> Lunch on day 5 @ 12:00 for 8 people.
Reservation RES-009: Dan < dan@email.com> Lunch on day 3 @ 13:00 for 2 people.
Reservation RES-010: Donna < donna@email.com> Lunch on day 5 @ 14:00 for 5 people.
Reservation RES-011: Ana < ana@email.com> Lunch on day 4 @ 15:00 for 4 people.
Reservation RES-012: John < john@email.com> Drinks on day 5 @ 16:00 for 2 people.
Reservation RES-013: Sara < sara@email.com> Dinner on day 3 @ 17:00 for 6 people.
Reservation RES-014: Jennifer < jenn@email.com> Dinner on day 5 @ 18:00 for 6 people.
Reservation RES-015: Stan < stan@email.com> Dinner on day 4 @ 19:00 for 5 people.
Reservation RES-016: Chris < chris@email.com> Dinner on day 4 @ 20:00 for 3 people.
Reservation RES-017: Vanessa < vanessa@email.com> Dinner on day 4 @ 21:00 for 4 people.
Reservation RES-018: David < david@email.com> Drinks on day 5 @ 22:00 for 4 people.
Reservation RES-019: Chris < chris@email.com> Drinks on day 3 @ 23:00 for 1 people.
Reservation RES-020: Donna < donna@email.com> Drinks on day 4 @ 24:00 for 3 people.
--------------------------
The at-home part of this workshop upgrades your in-lab solution to include two more modules:
The module Reservation dosn't need any change.
Restaurant Module
Add a Restaurant module to your project. This module should maintain a dynamically allocated array of objects of type Reservation: Reservation* (each element of the array is an object of type Reservation).
Public Members
Friend Helpers
overload the insertion operator to insert the content of a Restaurant object into an ostream object:
if there are no reservations:
--------------------------
Fancy Restaurant
--------------------------
The object is empty!
--------------------------
if there are reservations:
--------------------------
Fancy Restaurant
--------------------------
RESERVATION
RESERVATION
...
--------------------------
ConfirmationSender Module
Add a ConfirmationSender module to your project. The purpose of this module is to receive all the reservations from multiple restaurants, and contact the recipients with a confirmation message.
This module should maintain a dynamically allocated array of pointers to objects of type Reservation: const sdds::Reservation** (each element of the array is a pointer to an object of type Reservation).
Public Members
Friend Helpers
overload the insertion operator to insert the content of a ConfirmationSender object into an ostream object:
if there are no reservations to confirm:
--------------------------
Confirmations to Send
--------------------------
The object is empty!
--------------------------
if there are reservations to confirm
--------------------------
Confirmations to Send
--------------------------
RESERVATION
RESERVATION
...
--------------------------
Sample Output
When the program is started with the command:
w4.exe data.txt
the output should look like:
Command Line:
--------------------------
1: w4.exe
2: data.txt
--------------------------
Reservations
--------------------------
Reservation RES-001: John < john@email.com> Drinks on day 3 @ 5:00 for 2 people.
Reservation RES-002: David < david@email.com> Breakfast on day 4 @ 6:00 for 1 people.
Reservation RES-003: Sara < sara@email.com> Breakfast on day 5 @ 7:00 for 2 people.
Reservation RES-004: Ana < ana@email.com> Breakfast on day 5 @ 8:00 for 1 people.
Reservation RES-005: John < john@email.com> Breakfast on day 4 @ 9:00 for 1 people.
Reservation RES-006: Vanessa < vanessa@email.com> Drinks on day 3 @ 10:00 for 2 people.
Reservation RES-007: Mike < mike@email.com> Lunch on day 4 @ 11:00 for 4 people.
Reservation RES-008: Mike < mike@email.com> Lunch on day 5 @ 12:00 for 8 people.
Reservation RES-009: Dan < dan@email.com> Lunch on day 3 @ 13:00 for 2 people.
Reservation RES-010: Donna < donna@email.com> Lunch on day 5 @ 14:00 for 5 people.
Reservation RES-011: Ana < ana@email.com> Lunch on day 4 @ 15:00 for 4 people.
Reservation RES-012: John < john@email.com> Drinks on day 5 @ 16:00 for 2 people.
Reservation RES-013: Sara < sara@email.com> Dinner on day 3 @ 17:00 for 6 people.
Reservation RES-014: Jennifer < jenn@email.com> Dinner on day 5 @ 18:00 for 6 people.
Reservation RES-015: Stan < stan@email.com> Dinner on day 4 @ 19:00 for 5 people.
Reservation RES-016: Chris < chris@email.com> Dinner on day 4 @ 20:00 for 3 people.
Reservation RES-017: Vanessa < vanessa@email.com> Dinner on day 4 @ 21:00 for 4 people.
Reservation RES-018: David < david@email.com> Drinks on day 5 @ 22:00 for 4 people.
Reservation RES-019: Chris < chris@email.com> Drinks on day 3 @ 23:00 for 1 people.
Reservation RES-020: Donna < donna@email.com> Drinks on day 4 @ 24:00 for 3 people.
--------------------------
R: Testing Constuctor
==========================
--------------------------
Fancy Restaurant
--------------------------
Reservation RES-001: John < john@email.com> Drinks on day 3 @ 5:00 for 2 people.
Reservation RES-002: David < david@email.com> Breakfast on day 4 @ 6:00 for 1 people.
Reservation RES-003: Sara < sara@email.com> Breakfast on day 5 @ 7:00 for 2 people.
Reservation RES-004: Ana < ana@email.com> Breakfast on day 5 @ 8:00 for 1 people.
Reservation RES-005: John < john@email.com> Breakfast on day 4 @ 9:00 for 1 people.
Reservation RES-006: Vanessa < vanessa@email.com> Drinks on day 3 @ 10:00 for 2 people.
Reservation RES-007: Mike < mike@email.com> Lunch on day 4 @ 11:00 for 4 people.
Reservation RES-008: Mike < mike@email.com> Lunch on day 5 @ 12:00 for 8 people.
Reservation RES-009: Dan < dan@email.com> Lunch on day 3 @ 13:00 for 2 people.
Reservation RES-010: Donna < donna@email.com> Lunch on day 5 @ 14:00 for 5 people.
Reservation RES-011: Ana < ana@email.com> Lunch on day 4 @ 15:00 for 4 people.
Reservation RES-012: John < john@email.com> Drinks on day 5 @ 16:00 for 2 people.
Reservation RES-013: Sara < sara@email.com> Dinner on day 3 @ 17:00 for 6 people.
Reservation RES-014: Jennifer < jenn@email.com> Dinner on day 5 @ 18:00 for 6 people.
Reservation RES-015: Stan < stan@email.com> Dinner on day 4 @ 19:00 for 5 people.
Reservation RES-016: Chris < chris@email.com> Dinner on day 4 @ 20:00 for 3 people.
Reservation RES-017: Vanessa < vanessa@email.com> Dinner on day 4 @ 21:00 for 4 people.
Reservation RES-018: David < david@email.com> Drinks on day 5 @ 22:00 for 4 people.
Reservation RES-019: Chris < chris@email.com> Drinks on day 3 @ 23:00 for 1 people.
Reservation RES-020: Donna < donna@email.com> Drinks on day 4 @ 24:00 for 3 people.
--------------------------
==========================
R: Testing Copy Constuctor
==========================
--------------------------
Fancy Restaurant
--------------------------
Reservation RES-001: John < john@email.com> Drinks on day 3 @ 5:00 for 2 people.
Reservation RES-002: David < david@email.com> Breakfast on day 4 @ 6:00 for 1 people.
Reservation RES-003: Sara < sara@email.com> Breakfast on day 5 @ 7:00 for 2 people.
Reservation RES-004: Ana < ana@email.com> Breakfast on day 5 @ 8:00 for 1 people.
Reservation RES-005: John < john@email.com> Breakfast on day 4 @ 9:00 for 1 people.
Reservation RES-006: Vanessa < vanessa@email.com> Drinks on day 3 @ 10:00 for 2 people.
Reservation RES-007: Mike < mike@email.com> Lunch on day 4 @ 11:00 for 4 people.
Reservation RES-008: Mike < mike@email.com> Lunch on day 5 @ 12:00 for 8 people.
Reservation RES-009: Dan < dan@email.com> Lunch on day 3 @ 13:00 for 2 people.
Reservation RES-010: Donna < donna@email.com> Lunch on day 5 @ 14:00 for 5 people.
Reservation RES-011: Ana < ana@email.com> Lunch on day 4 @ 15:00 for 4 people.
Reservation RES-012: John < john@email.com> Drinks on day 5 @ 16:00 for 2 people.
Reservation RES-013: Sara < sara@email.com> Dinner on day 3 @ 17:00 for 6 people.
Reservation RES-014: Jennifer < jenn@email.com> Dinner on day 5 @ 18:00 for 6 people.
Reservation RES-015: Stan < stan@email.com> Dinner on day 4 @ 19:00 for 5 people.
Reservation RES-016: Chris < chris@email.com> Dinner on day 4 @ 20:00 for 3 people.
Reservation RES-017: Vanessa < vanessa@email.com> Dinner on day 4 @ 21:00 for 4 people.
Reservation RES-018: David < david@email.com> Drinks on day 5 @ 22:00 for 4 people.
Reservation RES-019: Chris < chris@email.com> Drinks on day 3 @ 23:00 for 1 people.
Reservation RES-020: Donna < donna@email.com> Drinks on day 4 @ 24:00 for 3 people.
--------------------------
--------------------------
Fancy Restaurant
--------------------------
Reservation RES-001: John < john@email.com> Drinks on day 3 @ 5:00 for 2 people.
Reservation RES-002: David < david@email.com> Breakfast on day 4 @ 6:00 for 1 people.
Reservation RES-003: Sara < sara@email.com> Breakfast on day 5 @ 7:00 for 2 people.
Reservation RES-004: Ana < ana@email.com> Breakfast on day 5 @ 8:00 for 1 people.
Reservation RES-005: John < john@email.com> Breakfast on day 4 @ 9:00 for 1 people.
Reservation RES-006: Vanessa < vanessa@email.com> Drinks on day 3 @ 10:00 for 2 people.
Reservation RES-007: Mike < mike@email.com> Lunch on day 4 @ 11:00 for 4 people.
Reservation RES-008: Mike < mike@email.com> Lunch on day 5 @ 12:00 for 8 people.
Reservation RES-009: Dan < dan@email.com> Lunch on day 3 @ 13:00 for 2 people.
Reservation RES-010: Donna < donna@email.com> Lunch on day 5 @ 14:00 for 5 people.
Reservation RES-011: Ana < ana@email.com> Lunch on day 4 @ 15:00 for 4 people.
Reservation RES-012: John < john@email.com> Drinks on day 5 @ 16:00 for 2 people.
Reservation RES-013: Sara < sara@email.com> Dinner on day 3 @ 17:00 for 6 people.
Reservation RES-014: Jennifer < jenn@email.com> Dinner on day 5 @ 18:00 for 6 people.
Reservation RES-015: Stan < stan@email.com> Dinner on day 4 @ 19:00 for 5 people.
Reservation RES-016: Chris < chris@email.com> Dinner on day 4 @ 20:00 for 3 people.
Reservation RES-017: Vanessa < vanessa@email.com> Dinner on day 4 @ 21:00 for 4 people.
Reservation RES-018: David < david@email.com> Drinks on day 5 @ 22:00 for 4 people.
Reservation RES-019: Chris < chris@email.com> Drinks on day 3 @ 23:00 for 1 people.
Reservation RES-020: Donna < donna@email.com> Drinks on day 4 @ 24:00 for 3 people.
--------------------------
==========================
R: Testing Move Constuctor
==========================
--------------------------
Fancy Restaurant
--------------------------
The object is empty!
--------------------------
--------------------------
Fancy Restaurant
--------------------------
Reservation RES-001: John < john@email.com> Drinks on day 3 @ 5:00 for 2 people.
Reservation RES-002: David < david@email.com> Breakfast on day 4 @ 6:00 for 1 people.
Reservation RES-003: Sara < sara@email.com> Breakfast on day 5 @ 7:00 for 2 people.
Reservation RES-004: Ana < ana@email.com> Breakfast on day 5 @ 8:00 for 1 people.
Reservation RES-005: John < john@email.com> Breakfast on day 4 @ 9:00 for 1 people.
Reservation RES-006: Vanessa < vanessa@email.com> Drinks on day 3 @ 10:00 for 2 people.
Reservation RES-007: Mike < mike@email.com> Lunch on day 4 @ 11:00 for 4 people.
Reservation RES-008: Mike < mike@email.com> Lunch on day 5 @ 12:00 for 8 people.
Reservation RES-009: Dan < dan@email.com> Lunch on day 3 @ 13:00 for 2 people.
Reservation RES-010: Donna < donna@email.com> Lunch on day 5 @ 14:00 for 5 people.
Reservation RES-011: Ana < ana@email.com> Lunch on day 4 @ 15:00 for 4 people.
Reservation RES-012: John < john@email.com> Drinks on day 5 @ 16:00 for 2 people.
Reservation RES-013: Sara < sara@email.com> Dinner on day 3 @ 17:00 for 6 people.
Reservation RES-014: Jennifer < jenn@email.com> Dinner on day 5 @ 18:00 for 6 people.
Reservation RES-015: Stan < stan@email.com> Dinner on day 4 @ 19:00 for 5 people.
Reservation RES-016: Chris < chris@email.com> Dinner on day 4 @ 20:00 for 3 people.
Reservation RES-017: Vanessa < vanessa@email.com> Dinner on day 4 @ 21:00 for 4 people.
Reservation RES-018: David < david@email.com> Drinks on day 5 @ 22:00 for 4 people.
Reservation RES-019: Chris < chris@email.com> Drinks on day 3 @ 23:00 for 1 people.
Reservation RES-020: Donna < donna@email.com> Drinks on day 4 @ 24:00 for 3 people.
--------------------------
==========================
CS: Testing Constuctor
==========================
--------------------------
Confirmations to Send
--------------------------
The object is empty!
--------------------------
==========================
CS: Testing Operators
==========================
--------------------------
Confirmations to Send
--------------------------
Reservation RES-006: Vanessa < vanessa@email.com> Drinks on day 3 @ 10:00 for 2 people.
Reservation RES-017: Vanessa < vanessa@email.com> Dinner on day 4 @ 21:00 for 4 people.
Reservation RES-009: Dan < dan@email.com> Lunch on day 3 @ 13:00 for 2 people.
--------------------------
--------------------------
Confirmations to Send
--------------------------
Reservation RES-006: Vanessa < vanessa@email.com> Drinks on day 3 @ 10:00 for 2 people.
Reservation RES-017: Vanessa < vanessa@email.com> Dinner on day 4 @ 21:00 for 4 people.
--------------------------
==========================
CS: Testing Copy Constuctor
==========================
--------------------------
Confirmations to Send
--------------------------
Reservation RES-006: Vanessa < vanessa@email.com> Drinks on day 3 @ 10:00 for 2 people.
Reservation RES-017: Vanessa < vanessa@email.com> Dinner on day 4 @ 21:00 for 4 people.
--------------------------
--------------------------
Confirmations to Send
--------------------------
Reservation RES-006: Vanessa < vanessa@email.com> Drinks on day 3 @ 10:00 for 2 people.
Reservation RES-017: Vanessa < vanessa@email.com> Dinner on day 4 @ 21:00 for 4 people.
--------------------------
==========================
CS: Testing Move Constuctor
==========================
--------------------------
Confirmations to Send
--------------------------
The object is empty!
--------------------------
--------------------------
Confirmations to Send
--------------------------
Reservation RES-006: Vanessa < vanessa@email.com> Drinks on day 3 @ 10:00 for 2 people.
Reservation RES-017: Vanessa < vanessa@email.com> Dinner on day 4 @ 21:00 for 4 people.
--------------------------
==========================