Coding Dojo

Edit on Gitlab

Cupcake

About this kata

This kata was originally made to implement the decorator and composite pattern.

Problem Description

Write a program that can build many cakes with many toppings like : “Cupcake with chocolate and nuts” Or “🧁 with black 🍫 and 🥜 and 🍬”. Be carful the order of topping is very important.

Write a function or method that can show the name of cake.

Write a function that can show the price of cake. The price is composed of base cake price and topping price.

Bundle of non fresh cakes

Now it’s possible to make a bundle of cakes. The price of a bundle is 10% less than prices of each cake.

It’s possible to build a bundle of bundle with singles cakes.

Suggested Test Cases

Decorator pattern

In pseudocode to build a Cupcake with chocolate and nuts and sugar you will write

var myCake = Sugar(Nuts(Chocolate(Cupcake())))

With typing, we can start to test :

About name function or method

About price function or method

Bundle