Write a class called Hamburger in python
The Hamburger class should have the following fields:
The Hamburger class should have the following methods:
In the same file, write a main function to test the functionality of the Hamburger class.
class Hamburger: def __init__(self, weight, doneness, cheese, toppings): self.weight = weight self.doneness = doneness self.cheese = cheese self.toppings = toppings def set_weight(self, weight): self.weight = weight def set_doneness(self, doneness): self.doneness = doneness def set_cheese(self, cheese): self.cheese = cheese def set_toppings(self, toppings): self.toppings = toppings def get_weight(self): return self.weight def get_doneness(self): return self.doneness def get_cheese(self): return self.cheese def get_toppings(self): return self.toppings def bite(self): if self.weight >= 1: self.weight -= 1 def __str__(self): return "weight: {}, doneness: {}, cheese: {}, toppings: {}".format(self.weight, self.doneness, self.cheese, self.toppings) def main(): h = Hamburger(10, 'medium', True, ['lettuce', 'mayo']) print(h) main()
Get Answers For Free
Most questions answered within 1 hours.