Question: URGENT PYTHON Create a class named PizzaOrder that stores information about a single pizza. It should contain the following: Constant value MAX_TOPPINGS = 15 Private
URGENT PYTHON
Create a class named PizzaOrder that stores information about a single pizza.
It should contain the following:
Constant value
MAX_TOPPINGS = 15
Private instance variables to store
size - the size of the pizza (either small, medium, or large)
num_toppings - the number of toppings
toppings - a list of strings ["cheese", "onions", "shrooms", "Grilled chicken", " ...]
A constructor that sets all of the instance variables.
A method add_topping() that will take a string parameter, topping, and append() it to the toppings list as long as the number it items in the list does not exceed the class's static MAX_TOPPINGS.
A method named calc_cost( ) that returns a double that is the cost of the pizza.
Pizza cost is determined by:
Small: $10 + $2 per topping
Medium: $12 + $2 per topping
Large: $14 + $2 per topping
__str___(self) - a method that returns a String containing the pizza size and the pizza cost as calculated by calc_cost( ).
Write test code to create several pizzas and output their descriptions.
For example, a large pizza with one cheese, one Grilled chicken, and two avocado toppings should cost a total of $22.
Sample run:
Size: Large, Cheese Toppings: 1 Grilled chicken Toppings: 0 onions Toppings: 1. Cost: 18.0 Size: Medium, Cheese Toppings: 2 Grilled chicken Toppings: 2 onions Toppings: 0. Cost: 20.0 Size: Small, Cheese Toppings: 2 Grilled chicken Toppings: 1 onions Toppings: 1. Cost: 18.0 Total of the order: 56.0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
