From 58d208e33cbb4db5060352c20529e3981aa7c34f Mon Sep 17 00:00:00 2001 From: voknelim Date: Tue, 12 Mar 2019 18:42:37 +0100 Subject: [PATCH] ma pizza hawai --- .../res/pizza/domain/voknelim/Hawai.java | 19 +++++++++++ .../res/pizza/domain/voknelim/HawaiTest.java | 33 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 src/main/java/ch/heigvd/res/pizza/domain/voknelim/Hawai.java create mode 100644 src/test/java/ch/heigvd/res/pizza/domain/voknelim/HawaiTest.java diff --git a/src/main/java/ch/heigvd/res/pizza/domain/voknelim/Hawai.java b/src/main/java/ch/heigvd/res/pizza/domain/voknelim/Hawai.java new file mode 100644 index 0000000..1312e99 --- /dev/null +++ b/src/main/java/ch/heigvd/res/pizza/domain/voknelim/Hawai.java @@ -0,0 +1,19 @@ +package ch.heigvd.res.pizza.domain.voknelim; + +import ch.heigvd.res.pizza.domain.IProduct; + +import java.math.BigDecimal; + +public class Hawai implements IProduct { + + public final static String NAME = "Hawai"; + public final static BigDecimal PRICE = new BigDecimal(15); + + public String getName() { + return NAME; + } + + public BigDecimal getPrice(){ + return PRICE; + } +} diff --git a/src/test/java/ch/heigvd/res/pizza/domain/voknelim/HawaiTest.java b/src/test/java/ch/heigvd/res/pizza/domain/voknelim/HawaiTest.java new file mode 100644 index 0000000..e040561 --- /dev/null +++ b/src/test/java/ch/heigvd/res/pizza/domain/voknelim/HawaiTest.java @@ -0,0 +1,33 @@ +package ch.heigvd.res.pizza.domain.voknelim; + +import ch.heigvd.res.pizza.domain.Pizzaiolo; +import ch.heigvd.res.pizza.domain.jzaehrin.Hawai; +import ch.heigvd.res.pizza.protocol.OrderRequest; +import ch.heigvd.res.pizza.protocol.OrderResponse; +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class HawaiTest { + + @Test + void thePriceAndNameForHawaiShouldBeCorrect() { + Hawai pizza = new Hawai(); + assertEquals(pizza.getName(), Hawai.NAME); + assertEquals(pizza.getPrice(), Hawai.PRICE); + } + + @Test + void aPizzaioloShouldAcceptAnOrderForHawai() { + Pizzaiolo mario = new Pizzaiolo(); + String productName = "ch.heigvd.res.pizza.domain.voknelim.Hawai"; + int numberOfPizzas = 2; + OrderRequest request = new OrderRequest(numberOfPizzas, productName); + OrderResponse response = mario.order(request); + BigDecimal expectedTotalPrice = Hawai.PRICE.multiply(new BigDecimal(numberOfPizzas)); + assertEquals(expectedTotalPrice, response.getTotalPrice()); + } + +} \ No newline at end of file