From 8fa4ff836a3998173b0f106b0d9e911744f373d7 Mon Sep 17 00:00:00 2001 From: linuxhelp1 Date: Tue, 12 Mar 2019 08:00:05 +0100 Subject: [PATCH] add kadjibeer --- .../res/chill/domain/djeule2/KadjiBeer.java | 21 ++++++++++++ .../chill/domain/djeule2/KadjibeerTest.java | 32 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 src/main/java/ch/heigvd/res/chill/domain/djeule2/KadjiBeer.java create mode 100644 src/test/java/ch/heigvd/res/chill/domain/djeule2/KadjibeerTest.java diff --git a/src/main/java/ch/heigvd/res/chill/domain/djeule2/KadjiBeer.java b/src/main/java/ch/heigvd/res/chill/domain/djeule2/KadjiBeer.java new file mode 100644 index 0000000..ec30ecc --- /dev/null +++ b/src/main/java/ch/heigvd/res/chill/domain/djeule2/KadjiBeer.java @@ -0,0 +1,21 @@ +package ch.heigvd.res.chill.domain.djeule2; + +import ch.heigvd.res.chill.domain.IProduct; + +import java.math.BigDecimal; + +public class KadjiBeer implements IProduct { + + public final static String NAME = "Kadjibeer"; + public final static BigDecimal PRICE = new BigDecimal(3.0); + + @Override + public String getName() { + return NAME; + } + + @Override + public BigDecimal getPrice() { + return PRICE; + } +} diff --git a/src/test/java/ch/heigvd/res/chill/domain/djeule2/KadjibeerTest.java b/src/test/java/ch/heigvd/res/chill/domain/djeule2/KadjibeerTest.java new file mode 100644 index 0000000..511a490 --- /dev/null +++ b/src/test/java/ch/heigvd/res/chill/domain/djeule2/KadjibeerTest.java @@ -0,0 +1,32 @@ +package ch.heigvd.res.chill.domain.djeule2; + +import ch.heigvd.res.chill.domain.Bartender; +import ch.heigvd.res.chill.domain.wasadigi.Boxer; +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; + +class KadjibeerTest { + + @Test + void thePriceAndNameForBoxerShouldBeCorrect() { + KadjiBeer beer = new KadjiBeer(); + assertEquals(beer.getName(), KadjiBeer.NAME); + assertEquals(beer.getPrice(), KadjiBeer.PRICE); + } + + @Test + void aBartenderShouldAcceptAnOrderForBoxer() { + Bartender jane = new Bartender(); + String productName = "ch.heigvd.res.chill.domain.djeule2.KadjiBeer"; + OrderRequest request = new OrderRequest(2, productName); + OrderResponse response = jane.order(request); + BigDecimal expectedTotalPrice = KadjiBeer.PRICE.multiply(new BigDecimal(2)); + assertEquals(expectedTotalPrice, response.getTotalPrice()); + } + +} \ No newline at end of file