Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fb carlsberg #800

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/main/java/ch/heigvd/res/chill/domain/gvetter/Cardinal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ch.heigvd.res.chill.domain.gvetter;

import ch.heigvd.res.chill.domain.IProduct;

import java.math.BigDecimal;

public class Cardinal implements IProduct {

public final static String NAME = "Cardinal";
public final static BigDecimal PRICE = new BigDecimal(2.3);

@Override
public String getName() {
return NAME;
}

@Override
public BigDecimal getPrice() {
return PRICE;
}
}
21 changes: 21 additions & 0 deletions src/main/java/ch/heigvd/res/chill/domain/gvetter/Carlsberg.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ch.heigvd.res.chill.domain.gvetter;

import ch.heigvd.res.chill.domain.IProduct;

import java.math.BigDecimal;

public class Carlsberg implements IProduct {

public final static String NAME = "Carlsberg";
public final static BigDecimal PRICE = new BigDecimal(2.9);

@Override
public String getName() {
return NAME;
}

@Override
public BigDecimal getPrice() {
return PRICE;
}
}
21 changes: 21 additions & 0 deletions src/main/java/ch/heigvd/res/chill/domain/gvetter/Valaisanne.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ch.heigvd.res.chill.domain.gvetter;

import ch.heigvd.res.chill.domain.IProduct;

import java.math.BigDecimal;

public class Valaisanne implements IProduct {

public final static String NAME = "Valaisanne";
public final static BigDecimal PRICE = new BigDecimal(2.8);

@Override
public String getName() {
return NAME;
}

@Override
public BigDecimal getPrice() {
return PRICE;
}
}
31 changes: 31 additions & 0 deletions src/test/java/ch/heigvd/res/chill/domain/gvetter/CardinalTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package ch.heigvd.res.chill.domain.gvetter;

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;

class CardinalTest {

@Test
void thePriceAndNameForCardinalShouldBeCorrect() {
Cardinal beer = new Cardinal();
assertEquals(beer.getName(), Cardinal.NAME);
assertEquals(beer.getPrice(), Cardinal.PRICE);
}

@Test
void aBartenderShouldAcceptAnOrderForCardinal() {
Bartender jane = new Bartender();
String productName = "ch.heigvd.res.chill.domain.gvetter.Cardinal";
OrderRequest request = new OrderRequest(3, productName);
OrderResponse response = jane.order(request);
BigDecimal expectedTotalPrice = Cardinal.PRICE.multiply(new BigDecimal(3));
assertEquals(expectedTotalPrice, response.getTotalPrice());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package ch.heigvd.res.chill.domain.gvetter;

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;

class CarlsbergTest {

@Test
void thePriceAndNameForCarlsbergShouldBeCorrect() {
Carlsberg beer = new Carlsberg();
assertEquals(beer.getName(), Carlsberg.NAME);
assertEquals(beer.getPrice(), Carlsberg.PRICE);
}

@Test
void aBartenderShouldAcceptAnOrderForCarlsberg() {
Bartender jane = new Bartender();
String productName = "ch.heigvd.res.chill.domain.gvetter.Carlsberg";
OrderRequest request = new OrderRequest(3, productName);
OrderResponse response = jane.order(request);
BigDecimal expectedTotalPrice = Carlsberg.PRICE.multiply(new BigDecimal(3));
assertEquals(expectedTotalPrice, response.getTotalPrice());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package ch.heigvd.res.chill.domain.gvetter;

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;

class ValaisanneTest {

@Test
void thePriceAndNameForValaisanneShouldBeCorrect() {
Valaisanne beer = new Valaisanne();
assertEquals(beer.getName(), Valaisanne.NAME);
assertEquals(beer.getPrice(), Valaisanne.PRICE);
}

@Test
void aBartenderShouldAcceptAnOrderForValaisanne() {
Bartender jane = new Bartender();
String productName = "ch.heigvd.res.chill.domain.gvetter.Valaisanne";
OrderRequest request = new OrderRequest(3, productName);
OrderResponse response = jane.order(request);
BigDecimal expectedTotalPrice = Valaisanne.PRICE.multiply(new BigDecimal(3));
assertEquals(expectedTotalPrice, response.getTotalPrice());
}

}