Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PYTHON 3 -Write a class called Hamburger. The Hamburger class should have the following fields, inputs should be done by user (ie. weight = input()
PYTHON 3 -Write a class called Hamburger.
The Hamburger class should have the following fields, inputs should be done by user (ie. weight = input()):
- weight an int storing the weight of the hamburger patty in ounces
- doneness a String which stores how well the burger is cooked i.e., rare, medium, well done, etc.
- cheese a boolean indicating whether the burger has cheese or not
- toppings a list of Strings storing the toppings on the burger i.e., lettuce, tomato, mayonnaise, etc.
The Hamburger class should have the following methods:
- a constructor
- getter and setter methods for each of the fields
- a bite method the bite methods should reduce the weight of the burger by 1 ounce each time its called until the weight is 0.
- __str__ method
In the same file, write a main function that prompts the user to input 3 hamburgers. The function outputs the hamburgers sorted by the weight, (hint: import operator). Then use any hamburger object to call the each of the class methods to test their functionality.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started