From e0d7694253727afbfbab14edc6150ab1140d12e2 Mon Sep 17 00:00:00 2001 From: Alain Gobet Date: Wed, 27 Feb 2019 19:27:14 +0100 Subject: [PATCH] Add Chouffe beer --- .../res/chill/domain/algobe/Chouffe.java | 21 ++++++++++++++ .../res/chill/domain/algobe/ChouffeTest.java | 29 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 src/main/java/ch/heigvd/res/chill/domain/algobe/Chouffe.java create mode 100644 src/test/java/ch/heigvd/res/chill/domain/algobe/ChouffeTest.java diff --git a/src/main/java/ch/heigvd/res/chill/domain/algobe/Chouffe.java b/src/main/java/ch/heigvd/res/chill/domain/algobe/Chouffe.java new file mode 100644 index 0000000..536d0fe --- /dev/null +++ b/src/main/java/ch/heigvd/res/chill/domain/algobe/Chouffe.java @@ -0,0 +1,21 @@ +package ch.heigvd.res.chill.domain.algobe; + +import ch.heigvd.res.chill.domain.IProduct; + +import java.math.BigDecimal; + +public class Chouffe implements IProduct { + + public final static String NAME = "Chouffe"; + public final static BigDecimal PRICE = new BigDecimal(4.5); + + @Override + public String getName() { + return NAME; + } + + @Override + public BigDecimal getPrice() { + return PRICE; + } +} diff --git a/src/test/java/ch/heigvd/res/chill/domain/algobe/ChouffeTest.java b/src/test/java/ch/heigvd/res/chill/domain/algobe/ChouffeTest.java new file mode 100644 index 0000000..d0d8c99 --- /dev/null +++ b/src/test/java/ch/heigvd/res/chill/domain/algobe/ChouffeTest.java @@ -0,0 +1,29 @@ +package ch.heigvd.res.chill.domain.algobe; + +import ch.heigvd.res.chill.domain.Bartender; +import ch.heigvd.res.chill.protocol.OrderRequest; +import ch.heigvd.res.chill.protocol.OrderResponse; +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ChouffeTest { + @Test + void thePriceAndNameForChouffeShouldBeCorrect() { + Chouffe beer = new Chouffe(); + assertEquals(beer.getName(), Chouffe.NAME); + assertEquals(beer.getPrice(), Chouffe.PRICE); + } + + @Test + void aBartenderShouldAcceptAnOrderForChouffe() { + Bartender jane = new Bartender(); + String productName = "ch.heigvd.res.chill.domain.algobe.Chouffe"; + OrderRequest request = new OrderRequest(3, productName); + OrderResponse response = jane.order(request); + BigDecimal expectedTotalPrice = Chouffe.PRICE.multiply(new BigDecimal(3)); + assertEquals(expectedTotalPrice, response.getTotalPrice()); + } +}