Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need some help with the code. 1. Dessert Shop Part 5: Overriding Methods Problem In this part of the project, you will override the

I need some help with the code.
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
1. Dessert Shop Part 5: Overriding Methods Problem In this part of the project, you will override the default magic method in all classes to enable printing a recept using the built-in function. You have implemented method in a previous project but now we present it in the context of overriding the default implementation. You may ask why we might implement methods specif cally when our order output is going to a PDF? Good questonl There are a few main answers: 1. 'Stringilying' an object ia helpful for debugging even if its not used in the actual appication. In this case, it could be usetur when dabugging Order code. 2. Another idea is to design objects to take advantage of leatures/plumbing in a language when it is convenient, in this case. (printer) wil call under the hood to print any object. We replace the defaut something more meaningful. Changes to dessertshop module - Commant out all the lines that print individual items to the consiole, if you have any. Delete them when you do not need them anymore - Replace that code with a single line that uses pint to print an ordes, for example Your code must still produce a correct While as in provious parts. Changes to the Concrete Subclasses of Dessertltem - add method to Candy, Cookie, loeCream, Sundae classes. Do not print in this method. Per the Python docs, this method returns a sting to the caller. Using candy com as an oxample, formatted lsom output would look like this: Candy Carn, 1,5ILA, 50,25/1B,50,34+10,03 The line gives item namo, quantiy, price per unit, cost, and tax lce Cream Sundaes are dittoront in that they have another line of comma separated values. AB always, I cuggest using totrings to build strings like this one. 1. Dessert Shop Part 5: Overriding Methods We tormat the item stnings this way because it makes the sting torm easeer to process programmatically, while still being human-readable. Changes to Order Class - add method oo Orcer class: The order should look lke the output from the example run below, in nice columns, when printed to the conscle. It is. OK to cun off the item narre if irs too long to print on one fine. Test Cases There are no new automated teet cases to add: fun your exsing autemated tast cases to make sure they stil pass. Then verity by manual inspecson that this nerw Version with overfidden string methods is cotrect. Example Scenario 1: Candyz 2. Cockie 3: Ice Cream 4: Sunday What would you like to add to the orded? (titi, Erier for done) 2 . Enter the type of cookie: Chocolate Chip Macadiarta Enter the quantity purchased: 5 Enter the price per dozen. 4.99 1. Candy 2. Cookie 3: lce Cream 4. Sunday What would you lice to add to the order? (14. Enter for done): 3 Enter the type of ice crearn: Mint Chocolate Chip Enter the number of scoope: 4 Enter the price per scoop. 89 1. Candy 2. Cookie 3. Ice Cream 4. Sumiay? What would you tike to add to the order? (1-4, Enter for done) 4 . Enter the type of ice cream. Varila. 1. Dessert Shop Part 5. Overriding Methods What would you like to add to the order? (14, Enter for donie) 4 Enter the fype of ice cream: Vanilla Enter the number of scoops 3 Enter the price per scoop 89 Enter the kind or topphg used: Sprinkles Enter the price for the topping: 5 1: Candy 2: Cookie 3. Ice Cream 4: Sunday What would you like to add to the order? (1.4, Enter for done): 1. Dessert Shop Part 5: Overriding Methods Changes to Receipt If your impiomentation of recelot.mea._ceceiyt ik) is correct; you should not have to modity it. But as you can see from the exarrile abcve, we have new information to include in our receipt. Grading There is no partial credit for inclvidual features. It any of them do not work, the maximum score for the project is 50%. Rubric printing happens only in main or input functions methods implemented correctly as directed above output to the console prints comma-separated values on a line like the example shown, lce Cream Sundae output has two lines like the example table shows. automated regression tests all still pass

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Describe the five elements of the listening process.

Answered: 1 week ago