Commit 19ea9300 authored by Gaetan's avatar Gaetan

Modification des tests unitaires

parent 51118632
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/garage/test" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/garage/test" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/garage/src" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/garage/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/garage/src/tests" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/.gradle" /> <excludeFolder url="file://$MODULE_DIR$/.gradle" />
<excludeFolder url="file://$MODULE_DIR$/build" /> <excludeFolder url="file://$MODULE_DIR$/build" />
</content> </content>
...@@ -13,8 +14,8 @@ ...@@ -13,8 +14,8 @@
<orderEntry type="module-library" scope="TEST"> <orderEntry type="module-library" scope="TEST">
<library name="JUnit4"> <library name="JUnit4">
<CLASSES> <CLASSES>
<root url="jar://$USER_HOME$/.m2/repository/junit/junit/4.12/junit-4.12.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.12/junit-4.12.jar!/" />
<root url="jar://$USER_HOME$/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />
......
import vehicle.part.option.Aircon;
import vehicle.part.option.CareerBars;
import vehicle.part.option.Option;
import java.util.List;
public class TestVehicle {
}
...@@ -128,28 +128,10 @@ public class Vehicle { ...@@ -128,28 +128,10 @@ public class Vehicle {
return options; return options;
} }
// DISPLAY ///////////////////////////////////////////////////////////////////////////////////////////////////////// public VehicleBrand getBrand(){
public void displayVehicleInformation(){ return this.brand;
// Clear screen
System.out.print("\033[H\033[2J");
System.out.flush();
System.out.println("|------------------------------------------------------------------|");
System.out.println("| VEHICULE INFORMATION |");
System.out.println("|------------------------------------------------------------------|");
System.out.println(" BRAND: " + brand + " MODEL: " + name +" PRICE: " + price);
System.out.println("|-----------------------------------------------------------------|");
} }
// Get the brand of the car
public VehicleBrand getBrand(){return this.brand;}
// Get the options of the car
// public List<vehicle.part.option> getOptions()
// Get the price
public double getPrice(List<Option> options){ public double getPrice(List<Option> options){
int index = 0; int index = 0;
double price = 0; double price = 0;
...@@ -158,11 +140,23 @@ public class Vehicle { ...@@ -158,11 +140,23 @@ public class Vehicle {
return price; return price;
} }
else{ else{
// price = options.Stream.forEach(o -> o.getPrice);
price = options.stream().collect(Collectors.summingDouble(Option::getPrice)); price = options.stream().collect(Collectors.summingDouble(Option::getPrice));
} }
return price; return price;
}
// DISPLAY /////////////////////////////////////////////////////////////////////////////////////////////////////////
public void displayVehicleInformation(){
// Clear screen
System.out.print("\033[H\033[2J");
System.out.flush();
System.out.println("|------------------------------------------------------------------|");
System.out.println("| VEHICULE INFORMATION |");
System.out.println("|------------------------------------------------------------------|");
System.out.println(" BRAND: " + brand + " MODEL: " + name +" PRICE: " + price);
System.out.println("|-----------------------------------------------------------------|");
} }
} }
\ No newline at end of file
public class TestVehicle {
}
Markdown is supported
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