From the course: C++ Design Patterns: Structural
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Challenge: Pizza toppings - C++ Tutorial
From the course: C++ Design Patterns: Structural
Challenge: Pizza toppings
(upbeat music) - [Instructor] Now that we've seen how the decorator pattern can be used to add new functionalities to objects dynamically, how about solving a design problem on your own? The challenge is to design a pizza ordering system that allows customers to order pizzas with different toppings. The design should allow customers to choose any combination of toppings and calculate the final price at runtime. Here's the starter project for this challenge. We have a pizza abstract class and three concrete classes for margherita pizza, Hawaiian pizza, and pepperoni pizza. Your task is to come up with a decorator based solution that allows customers to add one or more toppings to the pizzas and calculate the final price at runtime. Here are some hints to get you started. You'll need a topping decorator class that implements and reps the pizza class to add additional toppings. You will also need classes for each type of…