Answered step by step
Verified Expert Solution
Link Copied!

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

  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

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

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

Students also viewed these Databases questions