The emphasis of this project is working with linked lists.
In this project you will add some options to the restaurant program to deal with menu items.
You will work with a MenuItem class that can be used to create nodes in a linked list of menu items. This class declares that there is a class Menu and a class Order that are "friend" classes; that is, those classes may access the private data members of the MenuItem class.
@@@ INCLUDE menuItem.h here
You will use this struct to build lists of menu items. You'll also create two classes: a Menu class, and an Order class. The definition of the Menu class appears below. Note that the Menu class declares the Order class to be a "friend" class. This allows the Order class' member functions to access the private data members of the Menu class.
class Menu { public: Menu(); // default constructor; creates blank menu void addMenuItem(const char * const name, int price); // adds a menu item to the list void listMatchingMenuItems(const char * const name) const; // lists (on cout) all menu items where the name matches MenuItem *findFirstMatchingMenuItem(const char * const name) const; // return pointer to first matching menu item, // or null pointer if not found private: MenuItem_S *head; MenuItem_S *tail; };
Now here's the order class:
class Order { public: Order(); // default constructor; creates blank menu bool addOrderItem(const char * const name, Menu & m); // search Menu m for item matching name. // if found, create a copy of the MenuItem, // add it to the order, and return true // if not found, return false void listOrderItems(); // lists (on cout) all menu items on the order private: MenuItem_S *head; MenuItem_S *tail; };
In this project, you are given the complete .h files. You are also given a two main programs that you can use as drivers to testing your class implementation. It is up to you to create the .cpp files.
Write the .cpp files, and then test that the classes work properly with the small test program. Then, try to get the files to work with the larger test program.
(You can imagine ways this code might be integrated with the Restaurant and Table classes from project 2. Because the time remaining in the semester is short, we will not implement that in this project. If you are going on to take CISC220 in the Spring, and want a project you can do on your own over winter session to keep your keep your programming skills sharp, this would be a fine thing to take on.)