This assignment is worth 100 points.
The restaurant has a menu where each menu item is listed by an item number, a name, a description and an ingredient list. This information is stored in menu.dat and is in the following format:
100, Hamburger The basic sandwich that makes everyone happy. 5 1 2001 Hamburger Bun 1 5000 Hamburger Patty 2 1011 Pickle Slice 1 1010 Tomato Slice 3 1009 Lettuce Leaf 101, Cheese Burger The American Classic. 5 1 2001 Hamburger Bun 1 5000 Hamburger Patty 2 1014 American Cheese Slice 1 1010 Tomato Slice 3 1009 Lettuce Leaf 200, Small French Fries Deep Fried Crunch 1 3 2010 Cut French Fries 201, Medium French Fries More Deep Fried Crunch 1 5 2010 Cut French Fries 202, Large French Fries Even More Deep Fried Crunch 1 8 2010 Cut French FriesSo to prepare a Hamburger, we need 1 bun, 1 patty, 2 pickles, 1 tomato slice and 3 lettuce leaves.
Please note that item numbers are unique. Further note that there will be no more than 50 menu items. There should be no errors in this file.
Your company maintains a second file, ingredients.dat which is a list of all ingredients used by the restaurant. The restaurant will have no more than 100 different ingredient types. This file is in the following format:
1009, Lettuce Leaf Single Leaf 30 1010, Tomato Slice Slice 10 1014, American Cheese Slice Slice 50 1011, Pickle Slice Slice 300 2001, Hamburger Bun Bun 8 2010, Cut French Fries 3 oz 20 5000, Hamburger Patty Patty 24So your restaurant receives tomatoes in a package of 10 slices.
This file will contain all ingredients needed to produce items on the menu. There will be no errors in this file.
Finally, you maintain an inventory file, inventory.dat, which lists the ingredients you have on hand. You store ingredients in two places, in the prep bin and in the warehouse. When filling an order, ingredients are removed from the prep bin, until this bin is empty or unable to fill an order. At that time, you need to request ingredients be moved from the warehouse to the prep bin. The inventory.dat file is in the following format:
1009, 5, 20 1010, 2, 10 1014, 20, 30 1011, 298, 3 2001, 1, 20 2010, 12, 200 5000, 2, 20This file indicates that you have 2 hamburger patties in the prep bin and 20 boxes of patties in the warehouse.
In this case, there is just one hamburger bun left in the bin, so if someone orders a hamburger, the buns will need to be restocked. This file only contains ingredients listed in the ingredients.dat file. All ingredients in that file will also be listed in this file. Initially there will be no errors in this file. Your program will be required to update this file and you should introduce no errors in this file as you process orders.
Orders are contained in a file called orders.txt which is in the following format:
ORDER 100 1 100 1 200 Order 101 2 101 2 200 3 202 Order 102 1 200This file will be in the correct format, with no errors.
Your program should process the orders.txt file, issuing orders to the warehouse and bin systems, maintaining inventory amounts, and responding to order requests. You will write actions to two files and the standard output stream. This output represents commands to the bin to cook system, warehouse system and customer order system.
Every action your system executes should have a sequence number. Each day, the sequence number starts at 1, and is incremented by one each time an action occurs. Every command written, to any output stream, should include this sequence number.
The bin to cook system (BTCS) delivers items from the prep bins to the cooks. This is a delicate system, and should never be told to deliver more items than the bin contains. So for example, an order to deliver two hamburger buns should not be issued if there is a single hamburger bun in the bin. Please note that a bin can hold no more than the capacity of a container of the item. So, for example, the hamburger bun bin can only hold 8 buns.
The BTCS responds to the following commands
Your program should issue commands to the BTCS by writing commands to the file BTCS.cmds.
The warehouse system (WS) delivers items from the warehouse to the BTCS. This system is also somewhat delicate and should never be issued an order to retrieve items which are not present. The system responds to a single order: sequence number FETCH itemnumber. So the command 101 FETCH 2001 will fetch a package of hamburger buns and deliver them to the BTCS. Instructions should be issued to the WS by writing commands to the file WS.cmds.
Finally you should respond to orders by writing items to the standard output. For example, processing order 100 should produce
98 Processing Order 100 99 Preparing 1 Hamburger 106 Delivering 1 Hamburger 107 Preparing 1 Small French Fries 109 Delivering 1 Small French Fries 110 Finished Processing Order 100 111 Processing Order 101Please use whitespace between orders in this output. You do not need to worry about plural of items, so you may have the line 124 Preparing 3 Hamburger.
If it is impossible to fill an order, due to a lack of ingredients, your program should print an appropriate message. You do not need to issue this message until you are unable to obtain an ingredient, so there may have been ingredients sent to the cook which will be unused. Do not worry about this. You should not, however send ingredients to the cook for an item which can not be completed. For example, if you are trying to prepare a hamburger but are out of Pickle Slice, it is acceptable to issue orders to the BTCS to deliver a 2001 and 5000, but you should not issue orders to deliver 1011, nor should you deliver 1010 or 1009.
If you do run out of an ingredient, you should also issue a statement to the standard output indicating that more of the item should be ordered.
So the following message should be issued if a Hamburger can not be delivered due to a shortage of pickles.
156 Preparing 1 Hamburger 159 Unable to deliver Hamburger out of Pickle Slice 160 Order more Pickle Slice
Once you have finished processing orders.txt you should update inventory.dat with the correct amounts.