Practice/Amazon/Design a Pizza Billing System
Object Oriented DesignMust
Design and implement an object-oriented pizza ordering system that calculates the total cost of a pizza based on its base type and selected toppings. The system should support multiple pizza varieties, each with its own base price, and allow customers to customize their order by adding various toppings, each with its own additional cost.
Your implementation should use proper OOP principles including encapsulation and allow for easy extension of pizza types and toppings in the future.
Pizza class that represents a pizza ordercalculatePizzaPrice that takes a pizza type and list of toppings, returning the formatted price as a string with 2 decimal placesExample 1:
Input: pizza_type = "Margherita", toppings = [] Output: "8.00" Explanation: A basic Margherita pizza with no additional toppings costs exactly the base price of $8.00
Example 2:
` Input: pizza_type = "Margherita", toppings = ["extra_cheese", "mushrooms", "olives"] Output: "11.25" Explanation: Starting with a Margherita base ($8.00), we add:
Example 3:
Input: pizza_type = "Pepperoni", toppings = ["jalapenos", "extra_cheese"] Output: "12.00" Explanation: Pepperoni base costs $10.00, plus jalapeños ($0.50) and extra cheese ($1.50) = $12.00