Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Created November 23, 2023 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trikitrok/d7de949826bdaefd1f8da2e534a7f930 to your computer and use it in GitHub Desktop.
Save trikitrok/d7de949826bdaefd1f8da2e534a7f930 to your computer and use it in GitHub Desktop.

Sixth iteration - New drink makers!

We move to new markets that use different drink makers.

In this iteration, your task is to make our CoffeeMachine work with two new models of drink maker:

  • DrinkMaker-1000
  • DrinkMaker-3000

Use cases

Your product owner has delivered the stories and here they are:

  • The DrinkMaker-1000 should receive the correct instructions for all the drinks.
  • The DrinkMaker-3000 should receive the correct instructions for all the drinks.

The CoffeeMachine should still work with the old DrinkMaker-800 model.

DrinkMaker-1000 protocol.

The DrinkMaker-1000 protocol is comprised of two functions:

  1. make: It is used to make drinks. It receives two parameters: a string indicating the drink and an integer indicating the number of sugars. Some examples:

    make("T", 1) -> DrinkMaker-1000 makes 1 tea with 1 sugar and a stick

    make("HC", 0) -> DrinkMaker-1000 makes 1 chocolate with no sugar - and therefore no stick

    make("C", 2) -> DrinkMaker-1000 makes 1 coffee with 2 sugars and a stick

  2. notify: It is used to deliver info messages to the customer. Some examples:

    notify("message-content") -> DrinkMaker-1000 forwards any message received onto the coffee machine interface for the customer to see

DrinkMaker-3000 protocol.

The DrinkMaker-3000 protocol is comprised of one function for each type of drink and a function to forwards messages to the user:

  1. makeCoffee: It is used to make coffee. It receives an integer indicating the number of sugars. Some examples:

    makeCoffee(0) -> DrinkMaker-3000 makes 1 coffee with no sugar - and therefore no stick

    makeCoffee(1) -> DrinkMaker-3000 makes 1 coffee with 1 sugar and a stick

  2. makeTea: It is used to make tea. It receives an integer indicating the number of sugars. Some examples:

    makeTea(0) -> DrinkMaker-3000 makes 1 tea with no sugar - and therefore no stick

    makeTea(2) -> DrinkMaker-3000 makes 1 tea with 2 sugar and a stick

  3. makeChocolate: It is used to make chocolate. It receives an integer indicating the number of sugars. Some examples:

    makeChocolate(0) -> DrinkMaker-3000 makes 1 chocolate with no sugar - and therefore no stick

    makeChocolate(2) -> DrinkMaker-3000 makes 1 chocolate with 2 sugar and a stick

  4. display: It is used to deliver info messages to the customer. Some examples:

    display("message-content") -> DrinkMaker-3000 forwards any message received onto the coffee machine interface for the customer to see

coffee machine

Hints

  1. To know how to spy and stub interactions with Jest have a look at these examples.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment