Você está na página 1de 1

CI346: Assignment

A takeaway restaurant has a number of cashiers who take orders from customers. The orders are added to a list of pending orders. There are several cooks working in the kitchen who each take the next order from the list, cook it and deliver it, and then go back to get another order to cook. 1. Model this using Java threads, with classes Cashier, Cook and OrderList to represent the elements of the simulation. A Cashier has a name and adds an order to the OrderList at random intervals (a random delay between orders of up to 5 seconds). The order information includes the Cashiers name, the current time, and an order number (where each order taken by anyone gets the next available order number). A Cook also has a name. Each Cook removes an order from the OrderList when one is available, takes a random amount of time to cook it (a random delay of up to 7 seconds) and then delivers it, which you can simulate by printing out the name of the Cook and the information from the order. Make sure everything is synchronized so that orders dont get lost and the delivery details do not get jumbled together when they are displayed. 2. Modify your simulation so that the Cashiers, Cooks and the OrderList can be run as a distributed system on independent machines. The Cashiers and Cooks will need to be given the address and port number of the machine running the OrderList as commandline parameters. Cashiers and Cooks should be able to be added or removed at will (simulating staff coming on duty and going off duty). Consider carefully how to allow staff to go off duty without losing any pending orders. 3. Modify your simulation once again so that when an order has been cooked, the Cook will report this directly to the Cashier who created the order. The Cashier should then simulate delivery by displaying the order information as before. 4. Re-implement your solution to question 1 using Ada instead of Java.

Hand-in date:
Your normal hand-in day during the week beginning Jan 11th 2010.

What you should hand in:


Printed program listings, together with a CD containing copies of your source code and ready-to-run compiled code. A printed description and critique of your solutions (which should for example cover potential synchronization issues and how you have resolved them in question 1, the application protocol which your classes use to communicate in questions 2 and 3, and a comparison of your Ada and Java solutions in question 4).

Marking scheme:
Question 1: D Questions 1 and 2: C Questions 1, 2 and 3: B All questions: A

Você também pode gostar