Exercises
8.1 Smoothie blender
Let’s get ready for some healthy exercise! You’re going to create a Smoothie class where you can add ingredients, print all ingredients in a smoothie, and even mix two smoothies together using +.
Add ingredients to taste:
- Define a
Smoothieclass and write a constructor (__init__) that takes in a list of smoothie ingredients. Mark the ingredients as private. - Add a method to add ingredients to the ingredient list.
- Define a method that prints a description of the smoothie when called.
- Use a dunder method to deal with situations where we try to add different smoothies together. For example, adding a smoothie with strawberry and banana with another that has kale and orange should create a new smoothie with all four ingredients. Make sure your code deals with duplicate ingredients.
- Create a few instances of
Smoothieand check if everything is working as it’s supposed to.
