A lot of things².

- Change DataParsing to a generic interface.
- Add PartiePoisson
- Add comments to Population class.
This commit is contained in:
2026-04-01 14:34:07 +02:00
parent 3a6968f40f
commit 6420a4c606
12 changed files with 401 additions and 54 deletions

View File

@@ -1,50 +1,118 @@
package ecoparasite.population;
package ecoparasite.population;
import java.util.HashMap;
import java.util.HashSet;
import ecoparasite.input.DataParsing;
import ecoparasite.input.InvalidParsingException;
import ecoparasite.input.RawData;
import ecoparasite.input.RawDataOverflow;
public class Population {
import java.util.HashMap;
import java.util.HashSet;
private String id;
private PopulationArgs total;
private HashMap<Integer,PopulationArgs> perYear;
/**
* Permet de gérer une population selon les années.
*/
public class Population implements DataParsing {
public Population(String id, PopulationArgs total, HashMap<Integer,PopulationArgs> perYear) {
this.id = id;
this.total = total;
this.perYear = perYear;
}
/**
* Espèce de la population.
*/
private String id;
public Population(String id, PopulationArgs total) {
this.id = id;
this.total = total;
this.perYear = new HashMap<>();
}
/**
* Les informations de la population sur le total.
*/
private PopulationArgs total;
public Population(String id) {
this.id = id;
this.total = null;
this.perYear = new HashMap<>();
}
public String getId() {
return id;
}
public PopulationArgs getTotal() {
return total;
}
public HashMap<Integer,PopulationArgs> getPerYear() {
return perYear;
}
public void setTotal(PopulationArgs total) {
this.total = total;
}
public void setPerYear(HashMap<Integer,PopulationArgs> perYear) {
this.perYear = perYear;
}
/**
* Les informations de la population par année.
* Clé : Année, Valeur : Informations de la population.
*/
private HashMap<Integer,PopulationArgs> perYear;
/**
* Constructeur.
* @param id Espèce
* @param total Les informations totales.
* @param perYear Les informations par année.
*/
public Population(String id, PopulationArgs total, HashMap<Integer,PopulationArgs> perYear) {
this.id = id;
this.total = total;
this.perYear = perYear;
}
/**
* Constructeur.
* Pour les informations par année, crée une HashMap vide. Devra être rempli après coup.
* @param id Espèce de la population.
* @param total Les informations totales.
*/
public Population(String id, PopulationArgs total) {
this.id = id;
this.total = total;
this.perYear = new HashMap<>();
}
/**
* Constructeur.
* Pour les informations du total, sont remplacés par null.
* Pour les informations par année, crée une HashMap vide. Devra être rempli après coup.
* @param id Espèce de la population.
*/
public Population(String id) {
this.id = id;
this.total = null;
this.perYear = new HashMap<>();
}
/*
GETTERS / SETTERS
*/
public String getId() {
return id;
}
public PopulationArgs getTotal() {
return total;
}
public HashMap<Integer,PopulationArgs> getPerYear() {
return perYear;
}
public void setTotal(PopulationArgs total) {
this.total = total;
}
public void setPerYear(HashMap<Integer,PopulationArgs> perYear) {
this.perYear = perYear;
}
/**
* Raccourci vers les méthodes de DataParsing.
* @param data Notre objet RawData.
* @param parseTypeId L'ID de parsing.
* @return
*/
public static HashSet<Population> parse(RawData data, int parseTypeId ) throws RawDataOverflow, InvalidParsingException {
switch (parseTypeId) {
case 1:
return PopulationParsing.parseParasitesPeru(data);
default:
throw new InvalidParsingException(parseTypeId, Population.class.getSimpleName() );
}
}
/**
* Raccourci vers les méthodes de DataParsing.
* Va par défaut faire ceux des parasites du Perou.
*
* @param data Notre objet RawData.
* @return Notre tableau de populations.
*/
public static HashSet<Population> parse(RawData data){
return PopulationParsing.parseParasitesPeru(data);
}
}