$25
Consider implementing a restaurant management system. The system should have three types of users: administrator, waiter and chef. The administrator can add, delete and modify existing products from the menu. The waiter can create a new order for a table, add elements from the menu, and compute the bill for an order. The chef is notified each time it must cook food that is ordered through a waiter.
Consider the system of classes in the diagram below.
To simplify the application, you may assume that the system is used by only one administrator, one waiter and one chef, and there is no need of a login process.
Solve the following:
1) Define the interface IRestaurantProcessing containing the main operations that can be executed by the waiter/administrator, as follows:
• Administrator: create new menu item, delete menu item, edit menu item
• Waiter: create new order; compute price for an order; generate bill in .txt format.
2) Define and implement the classes from the class diagram shown above:
• Use the Composite Design Pattern for defining the classes MenuItem, BaseProduct and CompositeProduct
• Use the Observer Design Pattern to notify the chef each time a new order containing a composite product is added.
3) Implement the class Restaurant using a predefined JCF collection that is based on a hashtable data structure. The hashtable key will be generated based on the class Order, which can have associated several MenuItems. Use JTable to display Restaurant related information.
• Define a structure of type Map<Order, Collection<MenuItem>> for storing the order related information in the Restaurant class. The key of the Map will be formed of objects of type Order, for which the hashCode() method will be overwritten to compute the hash value within the Map from the attributes of the Order (OrderID, date, etc.).
• Define an appropriate collection consisting of MenuItem objects to store the menu of the restaurant.
• Define a method of type “well formed” for the class Restaurant.
• Implement the class Restaurant using Design by Contract method (involving pre, post conditions, invariants, and assertions).
4) The menu items for populating the Restaurant object will be loaded/saved from/to a file using Serialization.
. Bibliography
• Java serialization o http://www.tutorialspoint.com/java/java_serialization.htm o https://www.baeldung.com/java-serialization o https://www.geeksforgeeks.org/serialization-in-java/ o https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html
• Java HashMap
o http://javarevisited.blogspot.ro/2011/02/how-hashmap-works-in-java.html
• Java assert o http://docs.oracle.com/javase/8/docs/technotes/guides/language/assert.html o http://javarevisited.blogspot.ro/2012/01/what-is-assertion-in-java-java.html o http://stackoverflow.com/questions/11415160/how-to-enable-the-java-keywordassert-in-eclipse-program-wise
o https://intellij-support.jetbrains.com/hc/en-us/community/posts/207014815-How-toenable-assert
• Adding custom tags to javadoc o https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#tag