Coding Dojo

Edit on Gitlab

Cupcake

About this kata

This kata was originaly made to implement the decorator and composit pattern.

Problem Description

Write a program that can build many cake 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 they can show the name of cake.

Write a function they can show the price of cake. The price is composed from 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 cakes.

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

Suggested Test Cases

Decorator pattern

In pseudo code 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 : * I can put a Cupcake in a variable of type Cake

About name function or method

About price function or method

Bundle