Write a class called Hamburger. The Hamburger class should have the following fields: 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: 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 it’s 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. Then use any hamburger object to call each of the class methods to test their functionality.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 1GZ
Question

Write a class called Hamburger.
The Hamburger class should have the following fields:

  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 it’s 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. Then use any hamburger object to call each of the class methods to test their functionality.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT