Commit f40c3037 authored by Arthur POIGNONNEC's avatar Arthur POIGNONNEC

Merge branch 'master' of https://gvipers.imt-lille-douai.fr/arthur.poignonnec/geometry

# Conflicts:
#	garage/src/Option/Option.java
#	garage/src/vehicle/part/engine/Engine.java
parent 947e65b6
......@@ -10,5 +10,15 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" scope="TEST">
<library name="JUnit4">
<CLASSES>
<root url="jar://$USER_HOME$/.m2/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!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="12" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/classes" />
</component>
</project>
\ No newline at end of file
package garage;
import java.lang.reflect.Method;
import java.util.List;
public class Task {
private Class clazz;
private Method method;
private List<Object> args;
private Integer t;
public Task(Class clazz, Method method, List<Object> args, Integer t) {
this.clazz = clazz;
this.method = method;
this.args = args;
this.t = t;
}
}
package garage;
import vehicle.Vehicle;
import java.util.ArrayList;
import java.util.List;
public class TestBench {
private Vehicle vehicle;
private List<Task> tasks;
private Double distance;
public TestBench() {
tasks = new ArrayList<>();
vehicle = null;
}
public void addVehicle(Vehicle vehicle){
if(this.vehicle == null){
this.vehicle = vehicle;
}else{
System.out.println("A car is already on the testbench");
}
}
public void removeVehicle(){
if(this.vehicle != null){
this.vehicle = null;
}else{
System.out.println("No vehicle in the test bench.");
}
}
public Vehicle swapVehicle(Vehicle vehicule){
if(this.vehicle != null){
Vehicle temp = this.vehicle;
this.vehicle = vehicule;
return temp;
}else{
System.out.println("No vehicle in the test bench.");
return null;
}
}
public void addTask(Task task){
tasks.add(task);
}
public void removeTask(Task task){
tasks.remove(task);
}
public Vehicle getVehicle(){
return this.vehicle;
}
public List<Task> getTasks(){
return tasks;
}
}
......@@ -11,6 +11,7 @@ import vehicle.part.pedal.PedalAccelerator;
import vehicle.part.pedal.PedalBrake;
import vehicle.part.pedal.PedalClutch;
import java.util.ArrayList;
import java.util.List;
public class Vehicle {
......@@ -49,11 +50,13 @@ public class Vehicle {
}
// CREATING BRAKES
brakes = new ArrayList<>();
for(Integer i = 0; i < model.getNbOfWheels(); i++ ){
brakes.add(new Brake(model.getBrakesType()));
}
// CREATING PEDALS
pedals = new ArrayList<>();
pedals.add(new PedalAccelerator(engine));
pedals.add(new PedalBrake(brakes));
if("MANUAL".equals(model.getEngineModel().getGearBoxType())) {
......@@ -63,6 +66,10 @@ public class Vehicle {
// METHODS /////////////////////////////////////////////////////////////////////////////////////////////////////////
public void update(){
}
// Print the name of the car with the options and the price.
// public String toString()
// return "\t" + this.brandName + "is a " + name + " with that options : + " ?? " + ". Price : " + price.
......@@ -89,6 +96,20 @@ public class Vehicle {
return frame.getWeight();
}
// 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("|-----------------------------------------------------------------|");
}
// Get the brand of the car
// public VehicleBrand getBrand()
......
......@@ -6,7 +6,8 @@ import vehicle.part.frame.FrameType;
public enum VehicleModel {
FIAT500(VehicleBrand.FIAT, "500", EngineModel.TDI_A_D, FrameType.MICRO, BrakeType.PAD_FX200, 4);
FIAT_500(VehicleBrand.FIAT, "500", EngineModel.TDI_A_D, FrameType.MICRO, BrakeType.PAD_FX200, 4),
PEUGEOT_5008(VehicleBrand.PEUGEOT, "5008", EngineModel.TDI_A_P, FrameType.SUV, BrakeType.DISC_FX200, 4);
private final VehicleBrand brand;
private final String name;
......
......@@ -2,6 +2,7 @@ package vehicle.part.frame;
import vehicle.part.door.Door;
import java.util.ArrayList;
import java.util.List;
public class Frame {
......@@ -18,6 +19,8 @@ public class Frame {
length = type.getLength();
width = type.getWidth();
height = type.getHeight();
doors = new ArrayList<>();
for(Integer i = 0; i < type.getNbOfDoors(); i++) doors.add(new Door());
}
......
......@@ -9,5 +9,4 @@ public class HotSeat implements Option {
public String toString() {
return "Hot seat (" + this.getPrice() + " €)";
}
}
}
import garage.Task;
import garage.TestBench;
import org.junit.Before;
import org.junit.Test;
import vehicle.Vehicle;
import vehicle.VehicleModel;
import vehicle.part.pedal.PedalAccelerator;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertNull;
public class TestBenchTest {
private TestBench testBench;
private Vehicle fiat500;
private Vehicle peugeot5008;
@Before
public void setUp(){
testBench = new TestBench();
fiat500 = new Vehicle(VehicleModel.FIAT_500);
peugeot5008 = new Vehicle(VehicleModel.PEUGEOT_5008);
}
@Test
public void addVehicleTest(){
assertNull(testBench.getVehicle());
testBench.addVehicle(fiat500);
assertEquals(fiat500, testBench.getVehicle());
}
@Test
public void addVehicleImpossibleTest(){
assertNull(testBench.getVehicle());
testBench.addVehicle(fiat500);
testBench.addVehicle(peugeot5008);
assertEquals(fiat500, testBench.getVehicle());
}
@Test
public void removeVehicleTest(){
testBench.addVehicle(fiat500);
assertEquals(fiat500, testBench.getVehicle());
testBench.removeVehicle();
assertNull(testBench.getVehicle());
}
@Test
public void removeVehicleImpossibleTest(){
testBench.removeVehicle();
assertNull(testBench.getVehicle());
}
@Test
public void swapVehicleTest(){
testBench.addVehicle(fiat500);
assertEquals(fiat500, testBench.getVehicle());
Vehicle swapped = testBench.swapVehicle(peugeot5008);
assertEquals(fiat500, swapped);
assertEquals(peugeot5008, testBench.getVehicle());
}
@Test
public void swapVehicleImpossibleTest(){
Vehicle swapped = testBench.swapVehicle(peugeot5008);
assertNull(swapped);
assertNull(testBench.getVehicle());
}
@Test
public void addTaskTest(){
}
}
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