Question: 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()):

  1. weight an int storing the weight of the hamburger patty in ounces
  2. doneness a String which stores how well the burger is cooked i.e., rare, medium, well done, etc.
  3. cheese a boolean indicating whether the burger has cheese or not
  4. 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:

  1. a constructor
  2. getter and setter methods for each of the fields
  3. 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.
  4. __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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!