Question: In this TMA, you will develop a prototype application to help ERP participants create their Order. To reduce complexity, ERP enrolment is out-of-scope, instead













In this TMA, you will develop a prototype application to help ERP participants create their "Order". To reduce complexity, ERP enrolment is out-of-scope, instead MOH will provide the participant list via a text file (Appendix A). Deduction of CDC vouchers/digital wallet is out-of-scope. However, your prototype application must produce the order file (Appendix C), so that ERP's partners and CDC can process accordingly. Question 5 (30 marks) In this question, you will implement the EatRightAdmin class and the prototype application focusing on the creation of "Order". You need to make use of the classes created in the previous questions. As ERP is a pilot programme, the EatRightAdmin class is to ensure that a participant can only submit up to 2 orders per day. This EatRightAdmin class will also contain the collections of participants, available Delis and information of orders submitted. Figure Q5 highlight the class diagram for EatRightAdmin EatRightAdmin _DAILY_QUOTA: 2 _participants: dictionary of Participant objects _delis: dictionary of Deli objects _orders: list _init__(self) setupParticipants(self): dictionary setupDelis(self): dictionary readOrders(self): list searchParticipant(self, id: str): Participant searchDeli(self, code): Deli listDelilnventory(self): str countOrders/self, id: str): int listOrders(self, id: str); str addOrder/self, participant: Participant, deliSet: DeliSet): Order saveOrders(self) Figure Q5 Implement the EatRightAdmin class. There is ONE class variable: DAILY QUOTA which is 2, representing the number of orders a participant can submit per day. There are THREE instance variables: o participants (dictionary): collection of ERP participants. The key for this dictionary is the participant's ID, and the value is the Participant object. o _delis (dictionary): collection of delis that ERP is offering. The key for this dictionary is the Deli code, and the value is the Deli object. o_orders (list): this is a list of Order objects, whereby the initial Order objects are created by reading the order information as shown in Appendix C. Constructor performs the following: o Invoke the setupParticipants method to setup Participant objects into the dictionary by reading the information from "Participants.txt". o Invoke the setupDelis method - to setup the Deli objects into the dictionary using the information provided in "Delis.txt". Invoke the readOrders method- to load the Order objects created (for next day) into a list. o Invoke the class method of Order: setNextID, so that the next order ID will continue from the last order created (if exists). Method setup Participants reads the information from "Participants.txt" to setup the ERP participants into the dictionary participants. See Appendix A for file content and format. Method setupDelis reads the information from "Delis.txt" to setup all the Delis currently offered by ERP into the dictionary _Delis. See Appendix B for file content and format. Method readOrders will attempt to find the order file for the next day (filename format "Order_YYYYMMDD.txt") and create an Order object before adding into the list_orders. File content is described in Appendix C. If the order file is not found, manage this exception, and initialise_orders to an empty list. Search for the correct Participant and Deli objects to create the Order object. Given an id as parameter, the method searchParticipant searches and returns the Participant object matching this id. If not found, the method returns None. Given a code as parameter, the searchDeli method searches and returns the Deli object that matches the parameter. If there is no such Deli, the method returns None. listDelilnventory method formats and returns the string representation of all Deli objects, concatenated and one Deli object per line. Example: Available Deli: =============== ceel Smoked Duck Salad cee2 - Strawberry Pudding cee3 - Chocolate Cake ce84 Smoked Salmon cees - chilled Papaya Smoothie cee6 Berry Yoghurt ce07- Beetroot Raita Heel Croissant H082 Chicken Pie H083 Roast Beef H084 - Asparagus & Poached Egg Hees - Apple Sesame Tart HOB6 H087 - Fish & Potato Pie Heas Banana Pancakes H0e9 Boiled Banana with Grated Coconut Hele - Buckwheat Pancakes H011 Chicken with Brown Rice H012 - Carrot & Coriander Soup H013 - Beancurd With Bean Sauce Beef & Brown Rice Spicy Soup Fat: 12.5 Fat: 0.3 Fat: 14.3 Fat: 3.7 Fat: 2.1 Price: $3.00 Price: $2.00 Price: $1.50 Price: $2.40 Price: $2.20 Price: $2.20 Price: $2.00 Price: $2.00 Price: $2.80 Price: $3.50 Price: $3.00 Price: $1.88 Price: $3.20 Price: $3.00 Price: $2.00 Price: $2.00 Price: $2.40 Price: $3.00 Price: $2.00 Fat: 1.0 Fat: 1.0 Fat: 7.5 Fat: 10.7 Fat: 21.8 Fat: 4.9 Fat: 7.5 Fat: 6.3 Fat: 5.5 Fat: 7.0 Fat: 2.2 Fat: 6.0 Fat: 5.8 Fat: 2.6 Price: $2.50 Fat: 3.3 Calories: 264.5 Calories: 45.5 Calories: 351.5 Calories: 97.3 Calories: 132.1 Calories: 57.8 Calories: 72.6 Calories: 130.3 Calories: 180.3 Calories: 274.6 Calories: 88.1 Calories: 283.5 Calories: 199.9 Calories: 175.5 Calories: 157.4 Calories: 150.6 Calories: 238.0 Calories: 253.4 Calories: 85.0 Calories: 97.7 countOrders method has 1 parameter: id. This method searches and returns the number of orders that has participant's id matching the parameter id. If there is no match, the method returns 0. The list Orders method has 1 parameter: id. This method will perform the following: Search for the participant using the given id. o If no such participant, then method should raise ERPException with proper message "You did not sign-up for this programme..." If participant is found, invoke the countOrders method. If there is no order, raise ERPException with message "You did not order any DeliSet..." (b) . If there are orders, the method formats and returns the order information, one per line: Your order(s) for 2023-08-26: =========== Order ID: 20230826001 ID: 54096807E Name: Wong Yong Heng Deliset: My Breakfast Price: $7.00 with Croissant, Smoked Duck Salad, Banana Pancakes Discounts: $1.00 Delivery Fee: $0.00 Final Price: $6.00 Order ID: 20230826003 ID: 54896807E Name: Wong Yong Heng Deliset: Heng Heng Snack Age: 83 Price: $3.50 with Chocolate Cake, Beetroot Raita Discounts: $1.00 Delivery Fee: $0.00 Final Price: $2.50 Consume in 1.5 hrs Age: 83 Consume in 0.5 hrs The addOrder method has a Participant object and a DeliSet object as parameters. This method is invoked when the participant is ready to create Order with the DeliSet. The following tasks need to be performed: o Check that the participant will not break the DAILY QUOTA, with this new order. If yes, this method should raise ERPExcpetion with message "You cannot exceed the daily quota...." If there is no exception, then proceed to: o Create the new Order object, with the given parameters. o Append this new Order object to the instance variable_orders. o Return the Order object. Healthier SG: Est-Right Programme 1. Order Deliset 2. List Orders 3. Quit The saveOrders method will write the return value of the getDetails method of the Order objects in the list _orders into the order file for next day. The file format is defined in Appendix C. There is no need to create the order file if there is no order. (18 marks) Write an application that allow ERP participants to submit and enquire their orders. As this is a pilot programme, the deduction of CDC vouchers/digital wallet will be out-of- scope. Instead, your application must provide the orders' information (Appendix C), so that ERP's partners and CDC can process manually. Before presenting the below menu, your application should create the EatRightAdmin object, so that the participants, delis, and any existing orders can be loaded. Enter choice: The next few paragraphs will explain the 3 options in detail. Option 1: Order DeliSet To order a DeliSet, the following steps and data elements should be collected: Prompt for participant id to help locate the Participant object. o If participant has enrolled in ERP, print his/her eligible discounts. o If there is no such participant, display appropriate message and return to menu. Healthier SG: Est-Right Programme =========== 1. Order Deliset 2. List Orders 3. Quit Enter choice: 1 Enter NRIC to start your order(s): 54096807E You are entitled to the following discount (s): Pioneer citizen: $1 discount Healthier SG: Est-Right Programme =============== ============ 1. Order Deliset 2. List Orders 3. Quit Enter choice: 1 Enter NRIC to start your order(s): S5572364H You are entitled to the following discount (s): Merdeka citizen: $0.50 discount, or $1 discount when order is more than $7 National Day Bonus: enjoy se% off Healthier SG: Est-Right Programme 1. Order Deliset 2. List Orders 3. Quit Enter choice: 1 Enter NRIC to start your order(s): 54096808e You did not sign up for this program Once the participant is located and entitled discounts shown, prompt the participant to enter the customised DeliSet name. This name will help participants to recognise when they enquire about their submitted orders. Next, display the available Delis to the participant to start assembling a Deli Set. Available Deli: ============== ceel Smoked Duck Salad ceez strawberry Pudding cees Chocolate Cake cee4 - Smoked Salmon cees - Chilled Papaya Smoothie cees - Berry Yoghurt cee7 - Beetroot Raita Heel - Croissant Heez Chicken Pie Hee3 Roast Beef Hee4 - Asparagus & Poached Egg Hees - Apple Sesame Tart Hees- Beef & Brown Rice Spicy Soup Hee7 - Fish & Potato Pie Hees Banana Pancakes Hee9 Hele H011 Chicken with Brown Rice He12 - Carrot & Coriander Soup H013 Beancurd With Bean Sauce Boiled Banana with Grated Coconut Buckwheat Pancakes Price: $3.00 Price: $2.00 Price: $1.50 Price: $2.40 Price: $2.20 Price: $2.20 Price: $2.00 Price: $2.00 Price: $2.80 Price: $3.50 Price: $3.00 Price: $1.80 Price: $3.20 Price: $3.00 Price: $2.00 Price: $2.00 Price: $2.40 Price: $3.00 Price: $2.00 Price: $2.50 Healthier SG: Est-Right Programme =========== Fat: 12.5 Fat: 0.3 Fat: 14.3 Fat: 3.7 Fat: 2.1 Fat: 1.0 Fat: 1.0 Fat: 7.5 Fat: 10.7 Fat: 21.8 Fat: 1. Order Deliset 2. List Orders Fat: 7.5 Fat: 6.3 Fat: 5.5 Fat: 7.0 Fat: Fat: 6.0 Fat: 5.8 Fat: Fat: 3.3 Prompt participant to enter the first deli code. o At this point if the participant press 3. Quit Enter choice: 1 Enter NRIC to start your order(s): $4096807E You are entitled to the following discount(s): Pioneer citizen: $1 discount Enter your customised set name: Heng Heng Snack Available Deli: =============== ceel - Smoked Duck Salad ceez - Strawberry Pudding cees Chocolate Cake cee4 - Smoked Salmon cees - Chilled Papaya Smoothie cees Berry Yoghurt cee7 - Beetroot Raita Heel - Croissant Heez Chicken Pie Hee3 Roast Beef Hee4- Asparagus & Poached Egg Hees - Apple Sesame Tart H807 Fish & Potato Pie Hees- Banana Pancakes Beef & Brown Rice Spicy Soup Hee9 Boiled Banana with Grated Coconut Hele Buckwheat Pancakes H011 - Chicken with Brown Rice H012 - Carrot & Coriander Soup H013 Beancurd With Bean Sauce Order ID: 20230826003 ID: 540968076 Select Deli by entering the code. to stop Deli : cee3 Ordering conset, Low atset, Low Carbset? : c Deli : H003 Add Deli failed. LowCarbset should not have more than see calories Deli : c807 Deli : Name: Wong Yong Heng Deliset: Heng Heng Snack Price: $3.50 with chocolate Cake, Beetroot Raita Discounts: $1.00 Delivery Fee: $0.00 Final Price: $2.50 Healthier SG: Est-Right Programme ======= 1. Order Deliset 2. List Orders 3. Quit Enter choice: 1 Price: $3.00 Price: $2.00 Price: $1.50 Price: $2.40 Price: $2.20 Price: $2.20 Price: $2.00 Price: $2.00 Price: $2.80 Price: $3.50 Price: $3.00 Price: $1.80 Price: $3.20 Price: $3.00 Price: $2.00 Price: $2.00 Price: $2.40 Price: $3.00 Price: $2.00 Price: $2.50 Age: 83 Enter NRIC to start your order(s): $5572364H You are entitled to the following discount(s): Enter your customised set name: Mok Meal Available Deli: =============== cee1 - Smoked Duck Salad ceez - strawberry Pudding Fat: 12.5 Fat: 0.3 Fat: 14.3 Fat: 3.7 Fat: 2.1 Fat: 1.0 Fat: 1.0 Fat: 7.5 Fat: 10.7 Fat: 21.8 Fat: 4.9 Fat: 7.5 Fat: 6.3 Fat: 5.5 Fat: 7.0 Fat: 2.2 Fat: 6.0 Fat: 5.8 Fat: 2.6 Fat: 3.3 Consume in 0.5 hrs Calories: 264.5 Calories: 45.5 Calories: 351.5 Calories: 97.3 Calories: 132.1 Calories: 57.8 Calories: 72.6 Calories: 130.3 Calories: 180.3 Calories: 274.6 Calories: 88.1 Calories: 283.5 Calories: 199.9 Calories: 175.5 Calories: 157.4 Calories: 150.6 Calories: 238.0 Calories: 253.4 Merdeka citizen: se.se discount, or $1 discount when order is more than $7 National Day Bonus: enjoy 50% off Calories: 85.0 Calories: 97.7 Price: $3.00 Fat: 12.5 Calories: 264.5 Calories: 45.5 Price: $2.00 Fat: 0.3 cees Chocolate Cake cee4 - Smoked Salmon cees - Chilled Papaya Smoothie cees- Berry Yoghurt cee7 - Beetroot Raita Heel Croissant Hee2 Chicken Pie Hee3 Roast Beef Hee4 - Asparagus & Poached Egg Hees - Apple Sesame Tart Hees- Beef & Brown Rice Spicy Soup H007- Fish & Potato Pie Hees Banana Pancakes Hee9 Boiled Banana with Grated Coconut Hele Buckwheat Pancakes H011 Chicken with Brown Rice H012 - Carrot & Coriander Soup H013 - Beancurd With Bean Sauce Select Deli by entering the code. to stop Deli : co01 Ordering conSet, Low atset, Low Carbset ?? F Deli : He13 Deli Hees Deli Order ID: 28230826004 ID: 55572364H Name: Sharon Mok Discounts: $4.75 Delivery Fee: $1.99 Final Price: $4.74 Price: $7.50 Healthier SG: Est-Right Programme ====== 1. Order Deliset 2. List Orders 3. Quit Deliset: Mok Meal Consume in 1.0 hrs with Smoked Duck Salad, Beancurd with Bean Sauce, Boiled Banana with Grated Coconut Enter choice: 1 Enter NRIC to start your order(s): 54428006 You are entitled to the following discount(s): Pioneer citizen: $1 discount Enter your customised set name: soft meal Available Deli: cee1 - Smoked Duck Salad ceez - strawberry Pudding cees Chocolate Cake cee4 Smoked Salmon cees - Chilled Papaya Smoothie cees- Berry Yoghurt cee7 - Beetroot Raita Heel Croissant Heez - Chicken Pie Hee3 Roast Beef Price: $1.50 Price: $2.40 Price: $2.20 Price: $2.20 Price: $2.00 Price: $2.00 Price: $2.80 Price: $3.50 Price: $3.00 Price: $1.80 Price: $3.20 Price: $3.00 Price: $2.00 Price: $2.00 Price: $2.40 Price: $3.00 Price: $2.00 Fat: Price: $2.50 Fat: 3.3 Age: 68 Hee4 - Asparagus & Poached Egg Hees - Apple Sesame Tart Hees- Beef & Brown Rice Spicy Soup Hee7 - Fish & Potato Pie Hees Banana Pancakes Hee9 Boiled Banana with Grated Coconut Hele Buckwheat Pancakes Fat: 14.3 Fat: 3.7 Fat: 2.1 Fat: 1.0 Fat: 1.0 Fat: 7.5 Fat: 10.7 Fat: 21.8 Fat: 4.9 Fat: 7.5 Fat: 6.3 Fat: 5.5 Fat: 7.8 Fat: 2.2 Fat: 6.0 Fat: 5.8 Calories: 351.5 Calories: 97.3 Calories: 132.1 Calories: 57.8 Calories: 72.6 Calories: 130.3 Calories: 180.3 Calories: 274.6 Calories: 88.1 Calories: 283.5 Calories: 199.9 Calories: 175.5 Calories: 157.4 Calories: 150.6 Calories: 238.0 Calories: 253.4 Calories: 85.0 Calories: 97.7 Fat: 12.5 Price: $3.00 Price: $2.00 Fat: 0.3 Price: $1.50 Fat: 14.3 Price: $2.40 Fat: 3.7 Price: $2.20 Fat: 2.1 Price: $2.20 Fat: 1.0 Price: $2.00 Fat: 1.0 Price: $2.00 Fat: 7.5 Price: $2.80 Fat: 10.7 Price: $3.50 Fat: 21.8 Price: $3.00 Fat: 4.9 Price: $1.80 Fat: 7.5 Price: $3.20 Fat: 6.3 Price: $3.00 Fat: 5.5 Price: $2.00 Fat: 7.0 Price: $2.00 Fat: 2.2 Price: $2.40 Fat: 6.0 Calories: 264.5 Calories: 45.5 Calories: 351.5 Calories: 97.3 Calories: 132.1 Calories: 57.8 Calories: 72.6 Calories: 130.3 Calories: 180.3 Calories: 274.6 Calories: 88.1 Calories: 283.5 Calories: 199.9 Calories: 175.5 Calories: 157.4 Calories: 150.6 Calories: 238.0 H011 Chicken with Brown Rice He12 - Carrot & Coriander Soup H013 Beancurd With Bean Sauce Select Deli by entering the code. to stop Deli
Step by Step Solution
3.31 Rating (142 Votes )
There are 3 Steps involved in it
Solutions Step 1 You must develop a Python class called Participant with particular instance variables and methods based on the description supplied Here is how the Participant class has been implemen... View full answer
Get step-by-step solutions from verified subject matter experts
