Question: Specifications for the Pizza class. The implementation of this class is almost simplistic! All of the methods ( except two ) are only single code

Specifications for the Pizza class.
The implementation of this class is almost simplistic! All of the methods (except two) are only single code statements. My class implementation is only 30 lines of code.
Class attributes
Remember that class members do not have a "self" prefix and are accessed with the class name and the dot operator.
1. Valid sizes for pizza contained in a collection at the class level.
You get to figure out the type of collection to store the sizes below.
Valid sizes are small, medium, large and x-large.
2. Another class level collection having the prices for each valid size.
You get to decide on the type of collection to store the prices below.
Prices are small: $6.49, medium: $8.49, large: $10.49, x-large: $13.49.
Constructor
Instance methods have an implicit first argument "self".
3. A constructor that takes a default size of medium and topping of a list of cheese that does the following:
a. Set the first argument size to the instance attribute size. Size must be verified. This can be done by setting the size property.
b. Creates an instance attribute a list with the second argument. If the second argument is missing, a single cheese topping is inserted in the list.
Instance methods
Instance methods have an implicit first argument "self".
4. A method that takes an argument of type list of strings. It adds topping to the list of pizza toppings.
5. Implement the __str__() method to return a formatted string. Examine the output from the test harness for clues on how to implement this method.
Instance Properties
Instance properties have an implicit first argument "self".
6. A property that returns the price of the pizza.
a. Price is based on the size as well as the number of toppings.
See spec#2 for cost based on size. Each topping cost an additional $0.50 each.
7. A property that returns the size of the pizza.
8. A property that sets the size of the pizza.
a. Size must be verified. A ValueError exception is raised if the size is invalid.
Instance Attributes
All of the following Instance attributes are initialized in the constructor from the values of the argument. Notice the __ prefix to make is private.
9.__size is a str that stores the size of this object. This is initialized in the constructor. It is mutated by the property in #8. It is returned in #7. It is used in #6 to calculate the cost of the pizza.
10.__toppings a list of string that represents the toppings for this object. This is initialized in the constructor. It is mutated in the add() method and is used in #6 to calculate the cost of the pizza.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!