Commit 23b372a2 authored by Arthur POIGNONNEC's avatar Arthur POIGNONNEC

[DEV] Evol modèle voiture (pièces)

parent fa45fb1e
......@@ -3,6 +3,8 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/garage/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/garage/test" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
......
<?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
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>
\ No newline at end of file
package Option;
public class Option {
}
......@@ -2,7 +2,7 @@ package main;
public class Main {
public static void main(String[] args) {
public static void main(String[] args) throws Exception {
// CREATE vehicle LAGUNA
......
package Vehicle;
package vehicle;
public enum Brand {
......@@ -16,17 +16,6 @@ public enum Brand {
return value;
}
/*
public static Brand getEnum(String value) {
for (Brand brand : Brand.values()) {
if (brand.getValue().equals(value)) {
return brand;
}
}
}
*/
public static boolean contains(String value) {
for (Brand brand : Brand.values()) {
if (brand.getValue().equals(value)) {
......
package Vehicle;
package vehicle;
public class Vehicle {
public abstract class Vehicle {
private static int numberOfVehicles = 0;
private Double price;
private String name;
// private options List<Option>
// private brandName Brand
private Brand brand;
private Double weight;
private Double length;
private Double width;
public Vehicle() {
numberOfVehicles++;
}
// METHODS
......
package vehicle.part.brake;
public class Brake{
private BrakeType type;
private Integer strength;
private Integer resistance;
private Double wear;
private Double state;
public Brake(BrakeType type) {
this.type = type;
this.strength = type.getStrength();
this.resistance = type.getResistance();
this.wear = 0d;
this.state = 0d;
}
public void update() {
}
public void setState(Double state){
this.state = state;
}
}
package vehicle.part.brake;
public enum BrakeType {
DISC_FX100(15, 1),
DISC_FX200(25,1),
DISC_FX300(30,2),
DISC_FX400(35,2),
DISC_FX500(50,3),
PAD_FX100(10, 1),
PAD_FX200(15,1),
PAD_FX300(25,2),
PAD_FX400(30,3),
PAD_FX500(45,4);
private final Integer strength;
private final Integer resistance;
BrakeType(Integer strength, Integer resistance) {
this.resistance = resistance;
this.strength = strength;
}
public Integer getStrength() {
return strength;
}
public Integer getResistance() {
return resistance;
}
}
package Engine;
package vehicle.part.engine;
public class DieselEngine extends Engine {
......@@ -9,6 +9,6 @@ public class DieselEngine extends Engine {
}
public String toString() {
return "Diesel Engine";
return "Diesel vehicle.parts.Engine";
}
}
package Engine;
package vehicle.part.engine;
public class ElectricEngine {
}
package Engine;
package vehicle.part.engine;
public class Engine {
......@@ -14,17 +14,11 @@ public class Engine {
}
public String toString() {
return "This vehicle has a " + cylindre + "engine, it's a " + type + " engine and it costs " + price + " €.";
return "This is a " + cylindre + "engine, it's a " + type + " engine and it costs " + price + " €.";
}
public String getCylindre() {
return this.cylindre;
}
public Double getPrice() {
}
}
package vehicle.part.engine;
public class EngineBrokenException extends Exception {
}
package Engine;
package vehicle.part.engine;
public enum EngineType {
......@@ -17,15 +17,14 @@ public enum EngineType {
return value;
}
/*
public static EngineType getEnum(String value) {
for (EngineType type : EngineType.values()) {
if (type.getValue().equals(value)) {
return type;
}
}
return null;
}
*/
public static boolean contains(String value) {
for (EngineType type : EngineType.values()) {
......
package Engine;
package vehicle.part.engine;
public class HybridEngine {
}
package Engine;
package vehicle.part.engine;
public class PetrolEngine {
}
package vehicle.part.gearbox;
public enum Gear {
REVERSE(-1),
NEUTRAL(0),
FIRST(1),
SECOND(2),
THRID(3),
FORTH(4),
FIFTH(5),
SIXTH(6);
private final Integer value;
Gear(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
public static Gear getEnum(Integer value) {
for (Gear type : Gear.values()) {
if (type.getValue().equals(value)) {
return type;
}
}
return null;
}
public static boolean contains(Integer value) {
for (Gear type : Gear.values()) {
if (type.getValue().equals(value)) {
return true;
}
}
return false;
}
}
package vehicle.part.gearbox;
import vehicle.part.engine.EngineBrokenException;
public interface GearBox {
void gearUp() throws StallException;
void gearDown() throws StallException;
void neutral() throws StallException;
void reverse() throws StallException, EngineBrokenException;
}
\ No newline at end of file
package vehicle.part.gearbox;
public class GearBoxAutomatic implements GearBox {
@Override
public void gearUp() {
}
@Override
public void gearDown() {
}
@Override
public void neutral() {
}
@Override
public void reverse() {
}
}
package vehicle.part.gearbox;
import vehicle.part.engine.Engine;
import vehicle.part.engine.EngineBrokenException;
public class GearBoxManual implements GearBox{
private Gear currentGear;
private Gear maxGear;
private Boolean engaged;
/**
* Constructor
* @param maxGear
*/
public GearBoxManual(Gear maxGear) {
this.maxGear = maxGear;
this.currentGear = Gear.NEUTRAL;
this.engaged = false;
}
/**
* Method to gear up
* @throws StallException
*/
@Override
public void gearUp() throws StallException{
if(engaged) {
if (!currentGear.equals(maxGear)) {
currentGear = Gear.getEnum(currentGear.getValue() + 1);
}
}
else
throw new StallException();
}
/**
* Method to gear down
* @throws StallException
*/
@Override
public void gearDown() throws StallException{
if(engaged) {
if (!currentGear.equals(Gear.REVERSE)) {
currentGear = Gear.getEnum(currentGear.getValue() - 1);
}
}
else
throw new StallException();
}
/**
* Go to neutral gear
* @throws StallException
*/
@Override
public void neutral() throws StallException{
if(engaged) {
currentGear = Gear.NEUTRAL;
}
else
throw new StallException();
}
/**
* Go to reverse gear
* @throws StallException
* @throws EngineBrokenException
*/
@Override
public void reverse() throws StallException, EngineBrokenException {
if(engaged) {
// TODO Récupérer la vitesse de la voiture pour savoir si le moteur casse
if(true) {
currentGear = Gear.REVERSE;
}else{
throw new EngineBrokenException();
}
}
else
throw new StallException();
}
/**
* Engage
*/
public void engage(){
engaged = true;
}
/**
* Disengage
*/
public void disengage(){
engaged = false;
}
}
package vehicle.part.gearbox;
public class StallException extends Exception {
public StallException() {
super("Le moteur a calé");
}
}
package vehicle.part.pedal;
public interface Pedal {
void setState(Double pressure);
void release();
void update();
}
package vehicle.part.pedal;
import vehicle.part.engine.Engine;
public class PedalAccelerator implements Pedal{
private Engine engine;
private Double state;
@Override
public void setState(Double pressure) {
this.state = pressure;
}
@Override
public void release() {
state = 0d;
}
@Override
public void update() {
}
}
package vehicle.part.pedal;
import vehicle.part.brake.Brake;
import java.util.List;
public class PedalBrake implements Pedal{
private List<Brake> brakes;
private Double state;
public PedalBrake(List<Brake> brakes) {
this.brakes = brakes;
}
@Override
public void setState(Double pressure) {
state = pressure;
}
@Override
public void release() {
state = 0d;
}
@Override
public void update() {
for(Brake brake : brakes){
brake.setState(state);
}
}
}
package vehicle.part.pedal;
import vehicle.part.gearbox.GearBox;
import vehicle.part.gearbox.GearBoxManual;
public class PedalClutch implements Pedal{
private GearBoxManual gearBox;
private Double state;
public PedalClutch(GearBoxManual gearBox) {
this.gearBox = gearBox;
this.state = 0d;
}
@Override
public void setState(Double pressure) {
state = pressure;
}
@Override
public void release() {
state = 0d;
}
@Override
public void update() {
if(state > 40d)
gearBox.engage();
else
gearBox.disengage();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="geometry" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" 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/main" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/tests" isTestSource="true" />
</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
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