Question 2 (18 marks) Demonstrate your understanding of how class hierarchy and association are used to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Question 2 (18 marks) Demonstrate your understanding of how class hierarchy and association are used to organize information, and then construct the class hierarchy and association according to specification. The class diagram in Figure Q2 shows the specifications of the Deli class and its subclasses: HotDeli and ColdDeli. STANDARD EXPIRY: 2 deliCode: str _name: str _price: float _fat: float _carbohydrates: float _protein: float expiryHours(self): float _init_(self, deliCode: str, name: str, price: float, Dell (abstract) delicode(self): str fat: float,carbohydrates: float, protein: float) name(self): str price(self): float fat(self): float ColdDeli _storageTemperature: float calories(self): float expiryHours(self): float (abstract) _str_(self): str _init__(self, deliCode: str, name: str, price: float, fat:float, carbohydrates: float, protein: float, storageTemperature: float) HotDeli _COOKING STYLE_EXPIRY: {"Steaming": 1. "Frying": 3. "Grilling": 1.8. "Roasting": 1.5) Figure Q2 cookingStyle: str _init__(self, deliCode: str, name: str, price: float, fat: float, carbohydrates: float, protein: float, cookingStyle: str) expiryHours(self): float Implement the abstract class - Deli. The Deli class represents a food item that the ERP is offering. ONE class variable that defines the standard expiry hours as 2. SIX instance variables: o _deliCode (str): unique code for this deli item, e.g., "H001". o name (str): name of the deli, e.g., "Croissant". o_price (float): the price for this deli. _fat (float): per serving of fat in grams. o carbohydrates (float): per serving of carbohydrates in grams. (c) . Define getter method for calories. Use the property decorator. To compute calories, use the following formula: o Fat provides 9 calories per gram while carbohydrates and protein each provide 4 calories per gram One abstract method, expiryHours which returns the standard expiry hours. . o protein (float): per serving of protein in grams. Constructor initialises these 6 instance variables using the given parameters. Getter methods for these instance variables: _deliCode, _name, price and _fat. Use the property decorator. The _str___ method returns a string representation of a Deli object, with selected attributes in the following order - deliCode, name, price, fat, and calories, in the suggest format below: cee1 - Smoked Duck Salad H001 Croissant Price: $4.00 Fat: 12.5 Price: $2.50 Fat: 15.0 Write the Python class definitions for the ColdDeli and HotDeli The ColdDeli class is a subclass of Deli, and it has One additional instance variable, storage Temperature (float) that will help determine how long this cold food item can last. (d) Write Python statements to create the appropriate Deli objects using the information below: Code Name ceel Smoked Duck Salad Heel Croissant Price Fat Carbohydrates Protein $3.00 12.5 $2.00 7.5 Print the details of the Deli objects created. 13.4 15 Storage Temperature 16c Cooking style Baking (2 marks) Question 2 (18 marks) Demonstrate your understanding of how class hierarchy and association are used to organize information, and then construct the class hierarchy and association according to specification. The class diagram in Figure Q2 shows the specifications of the Deli class and its subclasses: HotDeli and ColdDeli. STANDARD EXPIRY: 2 deliCode: str _name: str _price: float _fat: float _carbohydrates: float _protein: float expiryHours(self): float _init_(self, deliCode: str, name: str, price: float, Dell (abstract) delicode(self): str fat: float,carbohydrates: float, protein: float) name(self): str price(self): float fat(self): float ColdDeli _storageTemperature: float calories(self): float expiryHours(self): float (abstract) _str_(self): str _init__(self, deliCode: str, name: str, price: float, fat:float, carbohydrates: float, protein: float, storageTemperature: float) HotDeli _COOKING STYLE_EXPIRY: {"Steaming": 1. "Frying": 3. "Grilling": 1.8. "Roasting": 1.5) Figure Q2 cookingStyle: str _init__(self, deliCode: str, name: str, price: float, fat: float, carbohydrates: float, protein: float, cookingStyle: str) expiryHours(self): float Implement the abstract class - Deli. The Deli class represents a food item that the ERP is offering. ONE class variable that defines the standard expiry hours as 2. SIX instance variables: o _deliCode (str): unique code for this deli item, e.g., "H001". o name (str): name of the deli, e.g., "Croissant". o_price (float): the price for this deli. _fat (float): per serving of fat in grams. o carbohydrates (float): per serving of carbohydrates in grams. (c) . Define getter method for calories. Use the property decorator. To compute calories, use the following formula: o Fat provides 9 calories per gram while carbohydrates and protein each provide 4 calories per gram One abstract method, expiryHours which returns the standard expiry hours. . o protein (float): per serving of protein in grams. Constructor initialises these 6 instance variables using the given parameters. Getter methods for these instance variables: _deliCode, _name, price and _fat. Use the property decorator. The _str___ method returns a string representation of a Deli object, with selected attributes in the following order - deliCode, name, price, fat, and calories, in the suggest format below: cee1 - Smoked Duck Salad H001 Croissant Price: $4.00 Fat: 12.5 Price: $2.50 Fat: 15.0 Write the Python class definitions for the ColdDeli and HotDeli The ColdDeli class is a subclass of Deli, and it has One additional instance variable, storage Temperature (float) that will help determine how long this cold food item can last. (d) Write Python statements to create the appropriate Deli objects using the information below: Code Name ceel Smoked Duck Salad Heel Croissant Price Fat Carbohydrates Protein $3.00 12.5 $2.00 7.5 Print the details of the Deli objects created. 13.4 15 Storage Temperature 16c Cooking style Baking (2 marks)
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Please submit Steps 3, 4, 5, 6, and 7 separately, before submitting the completed project 1 In CCA 610: Cloud Services and Technology , you assumed the role of an IT analyst atBallotOnline, a company...
-
work on this professor Please submit Steps 3, 4, 5, 6, and 7 separately, before submitting the completed project 1 In CCA 610: Cloud Services and Technology , you assumed the role of an IT analyst...
-
Given the following data: Calculate ÎH for the reaction On the basis of enthalpy change, is this a useful reaction for the synthesis of ammonia? AH - 92 kJ () + AH = -484 k (g) ON OH 88
-
Mrs. Fugate, who is divorced, failed to include $28,000 alimony on her 2016 Form 1040. The only gross income she reported was her $78,000 salary. She filed her return on January 19, 2017. a. What is...
-
A department-store manager is interested in the number of complaints received by the customer-service department about the quality of electrical products sold by the store. Records over a 5-week...
-
US Obesity Levels by State and over Time These questions refer to the graphs found at http://stateofobesity.org/adult-obesity/ which show a sequence of maps of US states, colored by the proportion of...
-
Professor Schmidt, a geologist, has agreed to purchase McDonalds farm for a price of $2,000 per acre, which corresponds to the price of good quality farmland in the vicinity. However, Schmidt, on the...
-
Royal Lawncare Company produces and sells two packaged products-Weedban and Greengrow. Revenue and cost information relating to the products follow. Selling price per unit Variable expenses per unit...
-
Suppose that the stress in a fluid at point P is measured by placing a small transducer there and determining the force per unit area for different orientations of the transducer surface. The fol-...
-
Show the following transactions in the journals of L Buhinjak, initially assuming periodic inventory applies and then where perpetual inventory applies. 29 August 2022: Stock costing $1200 and tax...
-
J Leeson commenced business on 15 April 2022 with $5000 in the bank, GST receivable $350 and a computer valued at $3500. 20 April: Additional funds of $15 000 were injected by J Leeson into the...
-
On 1 March 2022, A Levstek commenced business with bank $10 000, GST receivable $4200, land $25 000, equipment $2000 and a motor vehicle $15 000. On 1 April 2022, A Levstek contributed further funds...
-
M Farrah purchased goods from D Michael for $25 905 ($23 550 + $2355 GST) on 15 April 2022. On 7 May a bill payable is signed, maturing on 28 November 2022. The bill is met on the due date. Show in...
-
On 18 February 2022, P Jackson sold stock to R Parramatta on credit for $3300 ($3000 + $300 GST); the cost of the goods sold was $1800. R Parramatta paid by cheque, which was banked on 27 February....
-
Alpha-Industrial Corporation buys 60 Gallons of lubricants from ABC petroleum for 50 JOD per gal to lubricate machines in the factory Machines are shut down for maintenance every 60 days. Each time...
-
A line l passes through the points with coordinates (0, 5) and (6, 7). a. Find the gradient of the line. b. Find an equation of the line in the form ax + by + c = 0.
-
Convert each of the following functional class IUPAC names to a substitutive name. (a) Ethyl isopropyl ketone (b) Methyl 2,2-dimethylpropyl ketone
-
Each of the following reactions has been reported in the chemical literature, and the principal organic product has been isolated in good yield Write a structural formula for the isolated product of...
-
Show by writing appropriate chemical equations how each of the following compounds could be converted to 3-hexyne: (a) 1-Butene (b) 1,1-Dichlorobutane (c) Acetylene
-
Define a closely held corporation.
-
Explain the role played by a board of directors of a corporation.
-
Explain the steps in forming a limited liability corporation.
Study smarter with the SolutionInn App