Question: In python! Define Pizza Define CustomPizza Pizza.py - Defines a Pizza class representing commonality for all Pizzas. For simplicity, this class will assume all Pizzas
In python!
Define Pizza
Define CustomPizza



Pizza.py - Defines a Pizza class representing commonality for all Pizzas. For simplicity, this class will assume all Pizzas have a size and price CustomPizza.py - Defines a child class of Pizza. This class should inherit all fields / methods from the Pizza class, but also introduces the concepts of toppings a customer can order (represented as a list of strings) SpecialtyPizza.py - Defines a child class of Pizza. This class should inherit all fields / methods from the Pizza class. Specialty pizzas are defined by a name attribute and all have a set price depending on the pizza size Pizza.py The Pizza.py file will contain the definition of a Pizza base class. We will define the Pizza attributes as follows: . price - float that represents the price of a pizza. Since the price will be defined by what type of pizza is ordered, we can simply create the price field and initialize it to 0.0 size - str that represents the size of the pizza being ordered. For simplicity, we can have three valid pizza sizes and and label these with "S" for small, "M" for medium, and "L" for large You should write a constructor that allows the user to construct a Pizza object by passing in values for the size. Your constructor should also create a price attribute and set it to 0.0. init__(self, size) Your Pizza class definition should also support the "getter" and "setter" methods for the price and size. Since this will be a base class for other Pizza types, anything we write here can be inherited by its child classes. getPrice(self) setPrice(self, price) getSize(self) setSize(self, size) . Custom Pizza.py and Specialty Pizza.py Pizza objects can be two different types. Both of these types of pizzas inherit from the Pizza class: 1. CustomPizza that allows the customers to add additional toppings of their choosing 2. SpecialtyPizza that has already been pre-configured and has a fixed price based on its size Custom Pizza.py Your CustomPizza class definition will be defined in CustomPizza.py. The CustomPizza class will contain a constructor that takes in the size of the Pizza, and should use this size to call our base class' constructor. In addition to the size, it will initialize a toppings list represented as a Python List. The price of a CustomPizza is defined by two things: 1. the size of the pizza 2. the number of toppings the pizza will have (assuming no toppings is a simple cheese pizza). CustomPizzas will have the following fixed prices based on its size: Small (S): $8.00 Medium (M): $10.00 Large (L): $12.00 The size of the pizza also dictates the amount each additional topping will cost based on the following definition: Small (S): + $0.50 per additional topping Medium (M): + $0.75 per additional topping Large (L): + $1.00 per additional topping Since we now know what the price of a pizza should be based on the size, the CustomPizza constructor should determine the base price of the pizza and set it appropriately (remember, no need to write it in this class if we already have the method in Pizza.py). _init__(self, size) There are two more methods this class should support: addTopping (self, topping) - this method will add to the toppings list and update its price appropriately. The topping parameter is represented as a str type getPizzaDetails(self) - this method will construct and return a string containing the details of the CustomPizza object including the size, toppings, and price of the CustomPizza. An example (with escape characters shown for formatting) is given below. When constructing your string, please follow the EXACT format since this is what Gradescope will expect CustomPizza without toppings example: cp1 = CustomPizza ("S") == assert cp1.getPizzaDetails() "CUSTOM PIZZA \ Size: S Toppings: \ Price: $8.00 " CustomPizza with a list of toppings example (note that each topping will be indented with a tab): cp1 = CustomPizza ("L") cp1.addTopping ("extra cheese") cp1. addTopping("sausage") assert cpi.getPizzaDetails() == \
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
