diff --git a/chill.iml b/chill.iml index 6ce9f62..f1f85c3 100644 --- a/chill.iml +++ b/chill.iml @@ -24,5 +24,12 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/java/ch/heigvd/res/chill/domain/djeule2/Castelbeer.java b/src/main/java/ch/heigvd/res/chill/domain/djeule2/Castelbeer.java new file mode 100644 index 0000000..3e54508 --- /dev/null +++ b/src/main/java/ch/heigvd/res/chill/domain/djeule2/Castelbeer.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 Castelbeer implements IProduct { + public final static String NAME = "Castelbeer"; + public final static BigDecimal PRICE = new BigDecimal(3.8); + + @Override + public String getName() { + return NAME; + } + + @Override + public BigDecimal getPrice() { + return PRICE; + } + +} diff --git a/src/main/java/ch/heigvd/res/chill/domain/djeule2/KingBeer.java b/src/main/java/ch/heigvd/res/chill/domain/djeule2/KingBeer.java new file mode 100644 index 0000000..d196958 --- /dev/null +++ b/src/main/java/ch/heigvd/res/chill/domain/djeule2/KingBeer.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 KingBeer implements IProduct { + public final static String NAME = "KingBeer"; + public final static BigDecimal PRICE = new BigDecimal(2.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/CastelbeerTest.java b/src/test/java/ch/heigvd/res/chill/domain/djeule2/CastelbeerTest.java new file mode 100644 index 0000000..13ac427 --- /dev/null +++ b/src/test/java/ch/heigvd/res/chill/domain/djeule2/CastelbeerTest.java @@ -0,0 +1,29 @@ +package ch.heigvd.res.chill.domain.djeule2; + +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 CastelbeerTest { + @Test + void thePriceAndNameForKingBeerShouldBeCorrect() { + Castelbeer beer = new Castelbeer(); + assertEquals(beer.getName(), Castelbeer.NAME); + assertEquals(beer.getPrice(), Castelbeer.PRICE); + } + + @Test + void aBartenderShouldAcceptAnOrderForKingBeer() { + Bartender jane = new Bartender(); + String productName = "ch.heigvd.res.chill.domain.djeule2.Castelbeer"; + OrderRequest request = new OrderRequest(2, productName); + OrderResponse response = jane.order(request); + BigDecimal expectedTotalPrice = Castelbeer.PRICE.multiply(new BigDecimal(2)); + assertEquals(expectedTotalPrice, response.getTotalPrice()); + } +} diff --git a/src/test/java/ch/heigvd/res/chill/domain/djeule2/KingBeerTest.java b/src/test/java/ch/heigvd/res/chill/domain/djeule2/KingBeerTest.java new file mode 100644 index 0000000..a0cb025 --- /dev/null +++ b/src/test/java/ch/heigvd/res/chill/domain/djeule2/KingBeerTest.java @@ -0,0 +1,29 @@ +package ch.heigvd.res.chill.domain.djeule2; + +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 KingBeerTest { + @Test + void thePriceAndNameForKingBeerShouldBeCorrect() { + KingBeer beer = new KingBeer(); + assertEquals(beer.getName(), KingBeer.NAME); + assertEquals(beer.getPrice(), KingBeer.PRICE); + } + + @Test + void aBartenderShouldAcceptAnOrderForKingBeer() { + Bartender jane = new Bartender(); + String productName = "ch.heigvd.res.chill.domain.djeule2.KingBeer"; + OrderRequest request = new OrderRequest(1, productName); + OrderResponse response = jane.order(request); + BigDecimal expectedTotalPrice = KingBeer.PRICE.multiply(new BigDecimal(1)); + assertEquals(expectedTotalPrice, response.getTotalPrice()); + } +}