Commit dc7e21b9 authored by Sibylle Peter's avatar Sibylle Peter
Browse files

started TDD market

parent dd5f0739
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
</content>
<orderEntry type="jdk" jdkName="17" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" scope="TEST">
<library name="JUnit5.7.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.7.0/junit-jupiter-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.7.0/junit-jupiter-api-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.7.0/junit-platform-commons-1.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.7.0/junit-jupiter-params-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.7.0/junit-jupiter-engine-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.7.0/junit-platform-engine-1.7.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
\ No newline at end of file
package market;
public class Booth {
private static final int BASE_TAX = 20;
public static final int PRICE_PER_METER = 10;
int price = BASE_TAX;
private int length;
private boolean table;
private boolean food;
public Booth(int length){
//TODO: refactor after calculate price works again.
//this(length, false, false);
this.length = length;
}
public Booth(int length, boolean table, boolean food) {
this.length = length;
this.table = table;
this.food = food;
}
private void calculatePrice(){
price += (length-2)* PRICE_PER_METER;
//TODO implement for table and food
}
public int getPrice() {
// TODO: should calculate price return price???
calculatePrice();
return price;
}
}
package market;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class BoothTest {
@Test
void testBoothWith3LMNoTableNoFood(){
//given lm 3, no table, no food
Booth booth = new Booth(3);
// when calculate price
// then price = 30 CHF
assertEquals(30, booth.getPrice());
}
@Test
void testBoothWith7mTableFood(){
//given lm 3, no table, no food
Booth booth = new Booth(7, true, true);
// when calculate price
// then price = 30 CHF
assertEquals(140, booth.getPrice());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment