Commit bc7f1c64 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
parents 23b372a2 97b957a8
This diff is collapsed.
......@@ -21,7 +21,7 @@ public abstract class Vehicle {
// return "\t" + this.brandName + "is a " + name + " with that options : + " ?? " + ". Price : " + price.
// Add an option
// public void addOption(opt : Option)
// public void addOption(opt : vehicle.part.option)
// GETTER
......@@ -31,7 +31,7 @@ public abstract class Vehicle {
// public Brand getBrand()
// Get the options of the car
// public List<Option> getOptions()
// public List<vehicle.part.option> getOptions()
// Get the price
// public Double getPrice();
......
package vehicle.part.engine;
public class DieselEngine extends Engine {
public class DieselEngine extends Engine{
public DieselEngine(String _cylindre, Double _price) {
......
package vehicle.part.engine;
public class ElectricEngine {
public class ElectricEngine extends Engine {
public ElectricEngine(String _cylindre, Double _price) {
super(_cylindre, _price);
this.type = EngineType.ELECTRIC;
}
public String toString() {
return "Electric Engine";
}
}
......@@ -3,22 +3,38 @@ package vehicle.part.engine;
public class Engine {
protected EngineType type;
private String cylindre;
private Double price;
protected String cylindre;
protected Double price;
public Engine (String _cylindre, Double _price) {
this.cylindre = _cylindre;
this.price = _price;
this.price = getPrice();
}
public String toString() {
return "This is a " + cylindre + "engine, it's a " + type + " engine and it costs " + price + " €.";
return "This vehicle has a " + cylindre + "engine, it's a " + type + " engine and it costs " + price + " €.";
}
public String getCylindre() {
return this.cylindre;
}
public Double getPrice() {
if (this.getClass() == DieselEngine.class) {
return 2000d;
} else if (this.getClass() == ElectricEngine.class) {
return 1800d;
} else if (this.getClass() == HybridEngine.class) {
return 3000d;
} else if (this.getClass() == PetrolEngine.class) {
return 1400d;
} else {
return 0d;
}
}
}
package vehicle.part.engine;
public class HybridEngine {
public class HybridEngine extends Engine {
public HybridEngine(String _cylindre, Double _price) {
super(_cylindre, _price);
this.type = EngineType.HYBRID;
}
public String toString() {
return "Hybrid Engine";
}
}
package vehicle.part.engine;
public class PetrolEngine {
public class PetrolEngine extends Engine {
public PetrolEngine(String _cylindre, Double _price) {
super(_cylindre, _price);
this.type = EngineType.PETROL;
}
public String toString() {
return "Petrol Engine";
}
}
package vehicle.part.option;
public class Aircon implements Option {
public double getPrice() {
return 300d;
}
public String toString() {
return "Aircon (" + this.getPrice() + " €)";
}
}
package vehicle.part.option;
public class CareerBars implements Option{
public double getPrice() {
return 100;
}
public String toString() {
return "Career bars (" + this.getPrice() + " €)";
}
}
package vehicle.part.option;
public class ElectricGlass implements Option{
public double getPrice() {
return 200d;
}
public String toString() {
return "Electric glass (" + this.getPrice() + " €)";
}
}
package vehicle.part.option;
public class GPS implements Option {
public double getPrice() {
return 50d;
}
public String toString() {
return "GPS (" + this.getPrice() + " €)";
}
}
package vehicle.part.option;
public class HotSeat implements Option {
public double getPrice() {
return 150d;
}
public String toString() {
return "Hot seat (" + this.getPrice() + " €)";
}
}
}
package vehicle.part.option;
public interface Option {
double getPrice();
String toString();
}
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