Let we start to design Object Oriented architecture of restaurant. Before start the design, we need to understand how a restaurant works.
Components required:
Customer
Name
Contact
selectDish(): Dish
Selects the dish from the menu.
callWaiter(): call upon a waiter.
placeOrder(d:Dish): Places the order and enjoy his meal once the dish is served on his table.
placeOrder(d:Dish): Places the order and enjoy his meal once the dish is served on his table.
requestBill(): Ask for the bill to the waiter.
makePayment(): Pays for the services.
Waiter
Name
EmpId
TableToWait
respondToCustomer(): Response to the customer’s calls on the tables he is waiting.
takeOrder(): Take the customer's order.
placeOrderToQueue(o:Order): Place the order in PendingOrderQueue.
handleOrderPreparedNotification(): Observer design pattern for notification
Wait for the order ready notifications.
serveDishToCustomer(d:Dish): Once notification is received, collects the dish and serves the dish to the corresponding customer.
takeBillRequest(): Receive the bill request from the customer.
acceptPayment(): Ask the Cashier to prepare the bill.
payMoneyToCashier(): Gives the bill to the customer and accepts the payment.
Chef
EmpId
prepareDish(d:Dish): Get the next order from the PendingOrderQueue.
placeOrderInFinishedQueue(): Prepares the dish and push the order to finished order queue.
notifyOrderComplete(): Observer design pattern for notification
Send a notification that the order is ready.
Cashier
Name
EmpId
prepareBill(o:Order): Accepts the prepare bill request from the waiter for the given order details. Prepares the bills and hands it over to the waiter.
acceptPayment(): Accept the cash from the waiter towards the order.
Order (DTO)
id
Dish
Data structure used:
PendingOrderQueue
addOrder(o:Order): Waiter will place the order in the PendingOrderQueue.
getNextOrder(): Chef gets the next order from the PendingOrderQueue.
FinishedOrderQueue
getFinishedOrder(o:Order): Chef will prepare the dish and push the order to FinishedOrderQueue.
Awesome article. Thanks for sharing such a useful information
ReplyDeleteThanks to share this great information.............................
ReplyDelete