The goal of this project is to provide practice in object-oriented design and implementation in the context of a realistic problem.
In this project, you will simulate the operations of a restaurant. You will write a set of classes which comprise a system that will model certain events. The events that can happen in this restaurant, along with implicit and actual things that should happen when these events occur, are summarized in the following table.
Event | Implicit effect | Explicit effect |
---|---|---|
A new server starts a shift | The new server is assigned a number (starting with 1) | |
A server ends a shift | The server's name and money made during the shift is printed to the screen | |
A new table starts | The table is assigned a number (starting with 1) | |
A table orders some food | The table's number and order is printed to the screen. | |
A table finishes and pays | The table's number and amount paid is printed to the screen. | |
A new item is added to the menu | The menu item is assigned a number (starting with 1) within its category |
Menu items fall under four categories: beverages, appetizers, main items, and value meals. Value meals are composed of one item each from the beverage, appetizer, and main item categories (for example, value meal #2 might be an order of beverage #3, appetizer #1, and main item #8). This is displayed as three separate orders, but has only one price. A "table" is actually a group of customers ordering together, not a physical table (so, if a table starts and is assigned id 3, and then later finishes, the number 3 is not available to be assigned to a new table that starts later; each group of customers has its unique id). Here's an example of a sequence of events.
The events will be read into your program from a file which will have one event per line, formatted in the following way. Typewriter font refers to literal characters, curly braces with italic describe the meaning of an integer value, and square braces with items separated by pipes indicate alternate options.
Event | Format | Example |
---|---|---|
A new server starts a shift | SS {server's name} |
SS Heidi |
A server ends a shift | SE {server's number} |
SE 3 |
A new table stars | NT {the tabe's server's number} |
NT 4 |
A table orders some food | TO {table's number} [B | A |
M | V ] {item's number} |
TO 3 A 7 |
A table finishes | TF {table's number} {tip percentage} |
TF 3 17 |
A new item is added to the menu | NM [ B | A | M |
V( {bev. number, app. number, main number}) ]
{price} |
NM V (2, 1, 5) 749 or NM B 149 |
You may assume that all the input is correct, including things like
Checkout the following code.
svn checkout file:///cslab/class/cs245/projects/proj3
Write a set of classes including one that implements the
interface RestaurantEventReader
, that is, which
has a method that takes a String representing the next even and
responds to it as described above.
Replace the reference to YourRestaurantEventReaderClass
in Restaurant.java
to whatever the name of your class is.
Use object-oriented style. Any time you are tempted to write a long if-else chain or a switch statement, you should ask yourself "is there a way to do this using polymorphism"? You will probably need to do some if-else-ing when parsing the event string; try to isolate this to one place in the code.
You also should write files that contain sequence of events as test cases. You are encouraged to share these with your classmates.
Your program may produce more output than what is specified above if you think it makes what's going on more clear.
Copy all the files you made or modified to a turn-in directory I've made for you.
cp
filename
/cslab/class/cs245/turnin/
{andrew,sarah,christopher,katelynn}
You are not required to turn in your test cases, but you may want to turn in one or two of them to demonstrate how you interpreted the specification of the event strings, in case there is any ambiguity.
DUE: Monday, Oct 8, 5:00 pm.