jhorlima / tests2solved-ts

Tests2Solved - Typescript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tests2Solved - Typescript

Open a pull request and submit your solution for this test with typescript.

Cupcake and Cookies: Decorator 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.

Decorator pattern

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

const myCake = new Sugar(new Nuts(new Chocolate(new Cupcake())));

About name function or method

  • The name function should return β€œπŸ§β€

  • The name function should return β€œπŸͺ”

  • The name function should return β€œπŸ§ with πŸ«β€

  • The name function should return β€œπŸͺ with πŸ«β€

  • The name function should return β€œπŸͺ with 🍫 and πŸ₯œβ€

  • The name function should return β€œπŸͺ with πŸ₯œ and πŸ«β€

About price function or method

  • The price function should return 1$ for β€œπŸ§β€

  • The price function should return 2$ for β€œπŸͺ”

  • The price function should return 1.1$ for β€œπŸ§ with πŸ«β€

  • The price function should return 2.1$ for β€œπŸͺ with πŸ«β€

  • The price function should return 2.2$ for β€œπŸͺ with πŸ₯œβ€

How to execute

Clone this project:

git clone https://github.com/jhorlima/tests2solved-ts.git

Enter in project folder:

cd tests2solved-ts

Install the dependencies:

npm ci

Run the tests:

npx jest

Fix classes so tests pass.

References

About

Tests2Solved - Typescript


Languages

Language:TypeScript 94.6%Language:JavaScript 5.4%