31.03.26 #4
@@ -9,5 +9,5 @@ import java.util.HashSet;
|
|||||||
*/
|
*/
|
||||||
public interface DataParsing {
|
public interface DataParsing {
|
||||||
|
|
||||||
public HashSet<Poisson> parse(RawData data);
|
public HashSet<Poisson> parse(RawData data) throws RawDataOverflow;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,13 @@ package ecoparasite.poisson;
|
|||||||
|
|
||||||
import ecoparasite.input.DataParsing;
|
import ecoparasite.input.DataParsing;
|
||||||
import ecoparasite.input.RawData;
|
import ecoparasite.input.RawData;
|
||||||
|
import ecoparasite.input.RawDataOverflow;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import static java.lang.Double.valueOf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hérite de Poisson.
|
* Hérite de Poisson.
|
||||||
* Ajoute les fonctions de Parsing liés aux données collectées sur le Mackerel.
|
* Ajoute les fonctions de Parsing liés aux données collectées sur le Mackerel.
|
||||||
@@ -16,8 +20,8 @@ public class Mackerel extends Poisson implements DataParsing {
|
|||||||
* @param length
|
* @param length
|
||||||
* @param infestation
|
* @param infestation
|
||||||
*/
|
*/
|
||||||
public Mackerel(Double length, Double infestation) {
|
public Mackerel(String id, Double length, Double infestation) {
|
||||||
super("Mackerel", length, null, infestation);
|
super(id, length, null, infestation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,11 +30,20 @@ public class Mackerel extends Poisson implements DataParsing {
|
|||||||
* @return tableau des poissons
|
* @return tableau des poissons
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public HashSet<Poisson> parse(RawData data) {
|
public HashSet<Poisson> parse(RawData data) throws RawDataOverflow {
|
||||||
|
|
||||||
|
HashMap<String,String> temp = new HashMap<>();
|
||||||
|
|
||||||
HashSet<Poisson> fishSet;
|
HashSet<Poisson> fishSet;
|
||||||
fishSet = new HashSet<>();
|
fishSet = new HashSet<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < data.getData().getFirst().size(); i++) {
|
||||||
|
temp = data.getEntry(i);
|
||||||
|
Poisson newP = new Mackerel(temp.get("Sample_code"),valueOf(temp.get("StandardLength")),valueOf(temp.get("NParasitesViscera")));
|
||||||
|
|
||||||
|
fishSet.add(newP);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return fishSet;
|
return fishSet;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,13 @@ package ecoparasite.poisson;
|
|||||||
|
|
||||||
import ecoparasite.input.DataParsing;
|
import ecoparasite.input.DataParsing;
|
||||||
import ecoparasite.input.RawData;
|
import ecoparasite.input.RawData;
|
||||||
|
import ecoparasite.input.RawDataOverflow;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import static java.lang.Double.valueOf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hérite de Poisson.
|
* Hérite de Poisson.
|
||||||
* Ajoute les fonctions de Parsing liés aux données collectées sur le Merlu.
|
* Ajoute les fonctions de Parsing liés aux données collectées sur le Merlu.
|
||||||
@@ -16,8 +20,8 @@ public class Merlu extends Poisson implements DataParsing {
|
|||||||
* @param length Un Wrapper Double representant la longueur/taille du poisson
|
* @param length Un Wrapper Double representant la longueur/taille du poisson
|
||||||
* @param infestation Un Wrapper Double representant le taux de parasite du poisson
|
* @param infestation Un Wrapper Double representant le taux de parasite du poisson
|
||||||
*/
|
*/
|
||||||
public Merlu(Double length, Double infestation) {
|
public Merlu(String id, Double length, Double infestation) {
|
||||||
super("Merlu", length, null, infestation);
|
super(id, length, null, infestation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,11 +30,20 @@ public class Merlu extends Poisson implements DataParsing {
|
|||||||
* @return tableau des poissons
|
* @return tableau des poissons
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public HashSet<Poisson> parse(RawData data) { //TODO
|
public HashSet<Poisson> parse(RawData data) throws RawDataOverflow {
|
||||||
|
|
||||||
|
HashMap<String,String> temp = new HashMap<>();
|
||||||
|
|
||||||
HashSet<Poisson> fishSet;
|
HashSet<Poisson> fishSet;
|
||||||
fishSet = new HashSet<>();
|
fishSet = new HashSet<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < data.getData().getFirst().size(); i++) {
|
||||||
|
temp = data.getEntry(i);
|
||||||
|
Poisson newP = new Merlu(temp.get("nom.merlu"),valueOf(temp.get("m.size")),valueOf(temp.get("number of Anisakis sp L3")));
|
||||||
|
|
||||||
|
fishSet.add(newP);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return fishSet;
|
return fishSet;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.HashSet;
|
|||||||
*/
|
*/
|
||||||
public class Poisson{
|
public class Poisson{
|
||||||
|
|
||||||
private String specie;
|
private String id;
|
||||||
private Double length;
|
private Double length;
|
||||||
private Double weight;
|
private Double weight;
|
||||||
private Double infestation;
|
private Double infestation;
|
||||||
@@ -16,13 +16,13 @@ public class Poisson{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructeur de l'objet Poisson
|
* Constructeur de l'objet Poisson
|
||||||
* @param specie Une String representant l'espece du poisson
|
* @param id Une String representant l'espece du poisson
|
||||||
* @param length Un Wrapper Double representant la longueur/taille du poisson
|
* @param length Un Wrapper Double representant la longueur/taille du poisson
|
||||||
* @param weight Un Wrapper Double representant le poids du poisson
|
* @param weight Un Wrapper Double representant le poids du poisson
|
||||||
* @param infestation Un Wrapper Double representant le taux de parasite du poisson
|
* @param infestation Un Wrapper Double representant le taux de parasite du poisson
|
||||||
*/
|
*/
|
||||||
public Poisson(String specie, Double length, Double weight, Double infestation){
|
public Poisson(String id, Double length, Double weight, Double infestation){
|
||||||
this.specie = specie;
|
this.id = id;
|
||||||
this.length = length;
|
this.length = length;
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
this.infestation = infestation;
|
this.infestation = infestation;
|
||||||
@@ -30,11 +30,11 @@ public class Poisson{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter de l'attribut specie
|
* Getter de l'attribut Id
|
||||||
* @return La string de l'attribut specie
|
* @return La string de l'attribut Id
|
||||||
*/
|
*/
|
||||||
public String getSpecie() {
|
public String getId() {
|
||||||
return specie;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user