Skip to content
Snippets Groups Projects
Commit 35d232db authored by Matias Mennecart's avatar Matias Mennecart
Browse files

commit fix bug

parent b3f7dc41
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
......@@ -9,16 +10,19 @@
<Stage fx:id="stage" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.univlille.sae.classification.controller.AddDataController">
<scene>
<Scene>
<AnchorPane prefHeight="406.0" prefWidth="385.0">
<AnchorPane prefHeight="458.0" prefWidth="389.0">
<children>
<VBox alignment="CENTER" layoutY="385.0" prefHeight="38.0" prefWidth="384.0" spacing="20.0">
<VBox alignment="CENTER" layoutX="1.0" layoutY="420.0" prefHeight="38.0" prefWidth="384.0" spacing="20.0">
<children>
<Button fx:id="confirmAdd" mnemonicParsing="false" onAction="#validate" stylesheets="@../css/style.css" text="Valider" textFill="WHITE">
<font>
<Font name="System Bold" size="13.0" />
</font></Button>
</children></VBox>
<VBox fx:id="entries" layoutY="16.0" prefHeight="366.0" prefWidth="385.0" spacing="10.0" />
<VBox fx:id="entries" layoutY="-4.0" prefHeight="424.0" prefWidth="390.0" spacing="10.0">
<opaqueInsets>
<Insets top="1.0" />
</opaqueInsets></VBox>
</children></AnchorPane>
</Scene>
</scene>
......
......@@ -3,7 +3,7 @@ package fr.univlille.sae.classification.model;
public enum DataType {
IRIS(4, Iris.class),
POKEMON(11, Pokemon.class);
POKEMON(12, Pokemon.class);
private final int argumentSize;
private final Class<? extends LoadableData> clazz;
......
......@@ -18,6 +18,10 @@ public abstract class LoadableData {
protected static int classificationType = 1;
// Ho-Ho 130, 30720, 3, 90, 1250000, 106, 154, 90 fire, flying, 199s
/**
* Constructeur par défaut.
*/
......
package fr.univlille.sae.classification.model;
import java.util.Arrays;
/**
* Usine pour créer des objets LoadableData en fonction du type de données.
*/
......@@ -15,7 +17,7 @@ public class PointFactory {
public static LoadableData createPoint(DataType type, Object[] coords) throws IllegalArgumentException {
int size = coords.length;
LoadableData data;
System.out.println("Arrays : " + Arrays.toString(coords) + " " + size);
switch (type) {
case IRIS:
if (size != DataType.IRIS.getArgumentSize()) {
......@@ -25,13 +27,17 @@ public class PointFactory {
break;
case POKEMON:
if(size != DataType.POKEMON.getArgumentSize()) {
throw new IllegalArgumentException("Le nombre de coordonnées doit être de 11 pour le type POKEMON.");
throw new IllegalArgumentException("Le nombre de coordonnées doit être de 12 pour le type POKEMON.");
}
data = null;
if (coords.length == 13) {
data = new Pokemon(coords);
try {
data = new Pokemon(coords);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException("Erreur lors de la création du Pokemon");
}
}
else if (coords.length == 11) {
else if (coords.length == 12) {
data = new Pokemon((String) coords[0], (Integer) coords[1], (Integer) coords[2], (Double) coords[3], (Integer) coords[4], (Integer) coords[5], (Integer) coords[6], (Integer) coords[7], (Integer) coords[8], "undefined", "", (Double) coords[9], (Boolean) coords[10]);
}
break;
......
......@@ -2,6 +2,7 @@ package fr.univlille.sae.classification.model;
import com.opencsv.bean.CsvBindByName;
import java.lang.reflect.Field;
import java.util.*;
public class Pokemon extends LoadableData{
......@@ -60,9 +61,23 @@ public class Pokemon extends LoadableData{
this.isLegendary = isLegendary;
}
public Pokemon(Object[] list) {
/** public Pokemon(Object[] list) {
this((String) list[0], (Integer) list[1], (Integer) list[2], (Double) list[3], (Integer) list[4], (Integer) list[5], (Integer) list[6], (Integer) list[7], (Integer) list[8], (String) list[9], (String) list[10], (Double) list[11], (Boolean) list[12]);
}
*/
public Pokemon(Object[] list) throws IllegalAccessException {
Field[] fields = getClass().getDeclaredFields();
for(int i = 0; i<fields.length; i++) {
if(i != LoadableData.classificationType) {
fields[i].set(this, list[i]);
}else if(fields[i].getType().equals(String.class)) {
fields[i].set(this, "undefinied");
}
}
}
/**
* Constructeur par défaut.
......
......@@ -22,7 +22,7 @@ import java.util.*;
*/
public abstract class DataVisualizationView {
private static Set<DataVisualizationView> views;
private static Set<DataVisualizationView> views = new HashSet<>();
public DataVisualizationController controller;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment