As mentioned in the introduction, ERP currently offers these 3 sets: EconSet, LowFatSet and Low CarbSet....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
As mentioned in the introduction, ERP currently offers these 3 sets: EconSet, LowFatSet and Low CarbSet. Participants can select their preferred Delis to form a Deli Set, as long as the Deli selections fit the criteria of these 3 sets. Figure Q3 shows the specifications of the Deli Set class and its subclasses: EconSet, LowFatSet and LowCarbSet. EconSet MAX DELI: 2 MAX PRICE: 6 SET TYPE: "E" addDelijself, deli: Deli) DellSet (abstract) _name: str deliList: list _init__(self, name: str, deli: Deli) name(self): str price(self): float consumeBy(self): float totalFat(self): float totalCalories(self): float setType(self): str getDeliCodes(self): str addDeli(self, dell: Deli) (abstract) _str_(self): str LowFatSet MAX FAT PERCENT: 10 SET TYPE: "F* addDeli(self, deli: Deli) LowCarbSet MAX CALORIES: 500 SET TYPE: "C" addDeli(self, deli: Deli) Figure Q3 Write a Python class definition for the exception class ERPException - subclass of the Exception class. This class has no added attribute or method. When the application encounters ERP rules violation, your application will raise an exception from this class. (1 mark) (6) Implement the abstract class-DeliSet. The DeliSet class has: TWO instance variables: o name (str): represents the customer defined name for this meal set. _deliList (list): a list containing the participant's selection of Deli objects for this meal set. The constructor performs the following: Initialise_name with the given parameter name. Initialise the deliList as a list with one Deli object, which is the given parameter deli . Getter method for instance variable: _name. Use the property decorator. In addition, define getter methods for the following. Use the property decorator. price: returns the sum of all delis' price. . consumeBy: returns the lowest expiry hours of all delis. o totalFat returns the sum of all delis' fat content. o totalCalories: returns the sum of all delis' calories. The method setType returns the subclasses class variable _SET_TYPE. Hint use type(self). getDeliCodes is a method that returns all the deliCode of the Deli objects in _deliList, separated by commas. E.g.. "H001.CO04,H009" One abstract method: addDeli that has a Deli object as parameter and adds it into the_deliList, only if the following condition is met: There is no duplicated Deli within this DeliSet (ie, cannot have same deliCode). Otherwise, raise ERPException with appropriate message. The _str_method returns a string representation of a DeliSet object, including the name of the DeliSet, price, consumeBy, then follow by the name of the Deli objects. This is an example in the suggested format: Deliset: My Lunch Set Price: $6.00 with Smoked Duck Salad, Strawberry Pudding Consume in 1.5 hrs (9 marks) Write the Python class definitions for the 3 subclasses of Deli Set: EconSet, LowFat Set and Low Carb Set. The EconSet class has: THREE class variables: _MAX_DELI, _MAX_PRICE and _SET_TYPE. Implement the method addDeli by checking the following rules: With this addition, the number of delis should not be more than _MAX_DELI Otherwise, raise ERPException with appropriate message. With this addition, the price of the DeliSet should not be more than _MAX_PRICE. Otherwise, raise ERPException with appropriate message. If the above rules are met, invoke the parent's class addDeli to proceed with the addition (d) The LowFatSet class has: TWO class variables: _MAX_FAT_PERCENT and _SET_TYPE Implement the method addDeli by ensuring that this condition is met . With this addition, the total fat content for the DeliSet should not be more than _MAX_FAT PERCENT. Le, LowFatSet must not have total fat > 10% of total calories. Otherwise, raise ERPException with appropriate message. If the above condition is met, invoke the parent's class addDeli to proceed with the addition. The Low Carb Set class has: TWO class variables: _MAX_CALORIES and _SET_TYPE. Implement the method addDeli by enforcing the following rule: With this addition, the total calories for this DeliSet should not be more than _MAX_CALORIES. Otherwise, raise ERPException with appropriate message. . If the above rule is met, invoke the parent's class addDeli to proceed with the addition (12 marks) Write a main() function with exception handling for the following: Referring to Appendix B for the list of Delis, create the following THREE DeliSet using the information below: . Econ Set, with any name and H006, then add the following Delis in this order: C005 H010 LowFatSet, with any name and H003, then add the following Delis in this order: H002 C003 C001 Low Carb Set, with any name and C004, then add the following Delis in this order. C007 H013 H012 H009 Print the string representation of the created Deli Set objects. (3 marks) As mentioned in the introduction, ERP currently offers these 3 sets: EconSet, LowFatSet and Low CarbSet. Participants can select their preferred Delis to form a Deli Set, as long as the Deli selections fit the criteria of these 3 sets. Figure Q3 shows the specifications of the Deli Set class and its subclasses: EconSet, LowFatSet and LowCarbSet. EconSet MAX DELI: 2 MAX PRICE: 6 SET TYPE: "E" addDelijself, deli: Deli) DellSet (abstract) _name: str deliList: list _init__(self, name: str, deli: Deli) name(self): str price(self): float consumeBy(self): float totalFat(self): float totalCalories(self): float setType(self): str getDeliCodes(self): str addDeli(self, dell: Deli) (abstract) _str_(self): str LowFatSet MAX FAT PERCENT: 10 SET TYPE: "F* addDeli(self, deli: Deli) LowCarbSet MAX CALORIES: 500 SET TYPE: "C" addDeli(self, deli: Deli) Figure Q3 Write a Python class definition for the exception class ERPException - subclass of the Exception class. This class has no added attribute or method. When the application encounters ERP rules violation, your application will raise an exception from this class. (1 mark) (6) Implement the abstract class-DeliSet. The DeliSet class has: TWO instance variables: o name (str): represents the customer defined name for this meal set. _deliList (list): a list containing the participant's selection of Deli objects for this meal set. The constructor performs the following: Initialise_name with the given parameter name. Initialise the deliList as a list with one Deli object, which is the given parameter deli . Getter method for instance variable: _name. Use the property decorator. In addition, define getter methods for the following. Use the property decorator. price: returns the sum of all delis' price. . consumeBy: returns the lowest expiry hours of all delis. o totalFat returns the sum of all delis' fat content. o totalCalories: returns the sum of all delis' calories. The method setType returns the subclasses class variable _SET_TYPE. Hint use type(self). getDeliCodes is a method that returns all the deliCode of the Deli objects in _deliList, separated by commas. E.g.. "H001.CO04,H009" One abstract method: addDeli that has a Deli object as parameter and adds it into the_deliList, only if the following condition is met: There is no duplicated Deli within this DeliSet (ie, cannot have same deliCode). Otherwise, raise ERPException with appropriate message. The _str_method returns a string representation of a DeliSet object, including the name of the DeliSet, price, consumeBy, then follow by the name of the Deli objects. This is an example in the suggested format: Deliset: My Lunch Set Price: $6.00 with Smoked Duck Salad, Strawberry Pudding Consume in 1.5 hrs (9 marks) Write the Python class definitions for the 3 subclasses of Deli Set: EconSet, LowFat Set and Low Carb Set. The EconSet class has: THREE class variables: _MAX_DELI, _MAX_PRICE and _SET_TYPE. Implement the method addDeli by checking the following rules: With this addition, the number of delis should not be more than _MAX_DELI Otherwise, raise ERPException with appropriate message. With this addition, the price of the DeliSet should not be more than _MAX_PRICE. Otherwise, raise ERPException with appropriate message. If the above rules are met, invoke the parent's class addDeli to proceed with the addition (d) The LowFatSet class has: TWO class variables: _MAX_FAT_PERCENT and _SET_TYPE Implement the method addDeli by ensuring that this condition is met . With this addition, the total fat content for the DeliSet should not be more than _MAX_FAT PERCENT. Le, LowFatSet must not have total fat > 10% of total calories. Otherwise, raise ERPException with appropriate message. If the above condition is met, invoke the parent's class addDeli to proceed with the addition. The Low Carb Set class has: TWO class variables: _MAX_CALORIES and _SET_TYPE. Implement the method addDeli by enforcing the following rule: With this addition, the total calories for this DeliSet should not be more than _MAX_CALORIES. Otherwise, raise ERPException with appropriate message. . If the above rule is met, invoke the parent's class addDeli to proceed with the addition (12 marks) Write a main() function with exception handling for the following: Referring to Appendix B for the list of Delis, create the following THREE DeliSet using the information below: . Econ Set, with any name and H006, then add the following Delis in this order: C005 H010 LowFatSet, with any name and H003, then add the following Delis in this order: H002 C003 C001 Low Carb Set, with any name and C004, then add the following Delis in this order. C007 H013 H012 H009 Print the string representation of the created Deli Set objects. (3 marks)
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
1. As shown by point D in Fig 3.1, the volume of an ideal diatomic gas is 2.00L at standard condition (STP, T=273.15K, P=101.3kPa). The gas is heated to A with its volume conserved, expands...
-
Smith Corporation produces bucket loader assemblies for the tractor industry. The product has a long-term life expectancy. Smith has decided to implement a JIT inventory system. Smith is deciding...
-
Suggest a possible structure for a compound with the formula C9H10O that has the following IR spectrum and explain yourreasoning: 100 - 50 1706 em- 4000 3500 3000 2500 2000 1000 500 1500 Wavenamber...
-
Youre considering an investment in Croatia that you expect will produce a 9 percent return next year, and you expect that your real rate of return on this investment will be 7 percent. What do you...
-
Product mix, special order. (N. Melumad, adapted) Pendleton Engineering makes cutting tools for metalworking operations. It makes two types of tools: R3, a regular cutting tool, and HP6, a...
-
push ('Arabic') push ('French') pop() push ('English') push ('Spanish') 1) Draw this stack (In an array of 5 elements implementation) 2) What is the language given by the Top element? 3) In which...
-
Macon Machines Company began operations on November 1, 2024. The main operating goal of the company is to sell high end robots. Customers may pay using cash or if appropriate, credit is extended to...
-
Discuss the uses and limits of ratio analysis and give three examples.
-
For the sequence \[x(n)= \begin{cases}1, & 0 \leq n \leq 1 \\ 0, & \text { otherwise }\end{cases}\] compute \(y(n)=x(n) * x(n) * x(n) * x(n)\). Check your results using the MATLAB function conv.
-
Home Innovations is evaluating a new product design. The estimated receipts and disbursements associated with the new product are shown below. MARR is 10 percent/year. a. What is the discounted...
-
Which of the following is a liability? (A) Machinery (B) Accounts payable for goods (C) Motor vehicles (D) Cash at bank
-
Which of the following should not be called 'Sales'? (A) Office fixtures sold (B) Goods sold on time (C) Goods sold for cash (D) Sale of item previously included in 'Purchases'
-
Which of the following best describes the meaning of 'Purchases'? (A) Items bought (B) Goods bought on time (C) Goods bought for resale (D) Goods paid for
-
The Rover 6 is a new custom-designed sports car. An analysis of the task of building the Rover 6 reveals the following list of relevant activities, their immediate predecessors, and their duration:2...
-
Fahrad Inc. sells all of its product on account. Fahrad has the following accounts receivable payment experience: Percent paid in the month of sale .........10 Percent paid in the month after the...
-
State the general steps of the P-value approach to hypothesis testing.
-
Explain the logic behind one-way ANOVA.
-
From the Florida State Center for Health Statistics report Women and Cardiovascular Disease Hospitalizations, we obtained the following frequency distribution showing who paid for the hospitalization...
-
To explore which conflict styles students would use in a variety of workplace scenarios. INSTRUCTIONS 1. Read each of the following workplace scenarios. 2. Next, choose the conflict style being used...
-
1. Working alone, complete the Listening Skills Survey. 2. In small groups, compare scores, discuss survey test items, and prepare responses to the discussion questions. 3. After the class...
-
The chapter included a paragraph on restaurant managers and staff communication about COVID-19 policies and practices. What would constitute transparency in the downward and upward directions? Data...
Study smarter with the SolutionInn App