2026-03-18 15:19:10 +01:00
|
|
|
package ecoparasite.poisson;
|
|
|
|
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
|
2026-03-18 16:45:42 +01:00
|
|
|
/**
|
|
|
|
|
* Classe générique pour un individu Poisson.
|
|
|
|
|
* Des types hérités plus précis, notamment pour le parsing sont disponibles dans le même paquet.
|
|
|
|
|
*/
|
2026-03-18 15:19:10 +01:00
|
|
|
public class Poisson{
|
|
|
|
|
|
2026-03-25 16:22:16 +01:00
|
|
|
private String id;
|
2026-03-18 15:19:10 +01:00
|
|
|
private Double length;
|
|
|
|
|
private Double weight;
|
|
|
|
|
private Double infestation;
|
|
|
|
|
protected HashSet<PartiePoisson> fishParts;
|
|
|
|
|
|
2026-03-18 15:37:18 +01:00
|
|
|
/**
|
|
|
|
|
* Constructeur de l'objet Poisson
|
2026-03-25 16:22:16 +01:00
|
|
|
* @param id Une String representant l'espece du poisson
|
2026-03-18 15:37:18 +01:00
|
|
|
* @param length Un Wrapper Double representant la longueur/taille du poisson
|
|
|
|
|
* @param weight Un Wrapper Double representant le poids du poisson
|
|
|
|
|
* @param infestation Un Wrapper Double representant le taux de parasite du poisson
|
|
|
|
|
*/
|
2026-03-25 16:22:16 +01:00
|
|
|
public Poisson(String id, Double length, Double weight, Double infestation){
|
|
|
|
|
this.id = id;
|
2026-03-18 15:19:10 +01:00
|
|
|
this.length = length;
|
|
|
|
|
this.weight = weight;
|
|
|
|
|
this.infestation = infestation;
|
2026-03-18 15:37:18 +01:00
|
|
|
this.fishParts = null;
|
2026-03-18 15:19:10 +01:00
|
|
|
}
|
|
|
|
|
|
2026-03-18 15:37:18 +01:00
|
|
|
/**
|
2026-03-25 16:22:16 +01:00
|
|
|
* Getter de l'attribut Id
|
|
|
|
|
* @return La string de l'attribut Id
|
2026-03-18 15:37:18 +01:00
|
|
|
*/
|
2026-03-25 16:22:16 +01:00
|
|
|
public String getId() {
|
|
|
|
|
return id;
|
2026-03-18 15:19:10 +01:00
|
|
|
}
|
|
|
|
|
|
2026-03-18 15:37:18 +01:00
|
|
|
/**
|
|
|
|
|
* Getter de l'attribut length
|
|
|
|
|
* @return Le Double de l'attribut length
|
|
|
|
|
*/
|
2026-03-18 15:19:10 +01:00
|
|
|
public Double getLength() {
|
|
|
|
|
return length;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-18 15:37:18 +01:00
|
|
|
/**
|
|
|
|
|
* Getter de l'attribut weight
|
|
|
|
|
* @return Le Double de l'attribut weight
|
|
|
|
|
*/
|
2026-03-18 15:19:10 +01:00
|
|
|
public Double getWeight() {
|
|
|
|
|
return weight;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-18 15:37:18 +01:00
|
|
|
/**
|
|
|
|
|
* Getter de l'attribut infestation
|
|
|
|
|
* @return Le Double de l'attribut infestation
|
|
|
|
|
*/
|
2026-03-18 15:19:10 +01:00
|
|
|
public Double getInfestation() {
|
|
|
|
|
return infestation;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 14:34:07 +02:00
|
|
|
/**
|
|
|
|
|
* Getter de l'attribut des parties de poisson.
|
|
|
|
|
* @return Le HashSet des parties de poisson.
|
|
|
|
|
*/
|
|
|
|
|
public HashSet<PartiePoisson> getFishParts() {
|
|
|
|
|
return fishParts;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 13:08:36 +00:00
|
|
|
/**
|
|
|
|
|
* Setter de l'attribut infestation
|
|
|
|
|
* @param infestation le Double de la nouvelle valeur de l'infestation
|
|
|
|
|
*/
|
|
|
|
|
public void setInfestation(Double infestation) {
|
|
|
|
|
this.infestation = infestation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2026-04-01 14:34:07 +02:00
|
|
|
/**
|
|
|
|
|
* Setter de l'attribut des parties de poisson.
|
|
|
|
|
* @param fishParts Un hashset de parties de poisson.
|
|
|
|
|
*/
|
|
|
|
|
public void setFishParts(HashSet<PartiePoisson> fishParts) {
|
|
|
|
|
this.fishParts = fishParts;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-18 15:37:18 +01:00
|
|
|
/**
|
|
|
|
|
* Permet d'afficher les informations de notre poisson
|
|
|
|
|
* @return La string contenant les informations
|
|
|
|
|
*/
|
2026-03-18 15:19:10 +01:00
|
|
|
@Override
|
|
|
|
|
public String toString(){
|
2026-03-31 19:00:19 +02:00
|
|
|
String result = "[ %5s : %4f mm, %4f g, %4f taux d'infestation ]";
|
|
|
|
|
return String.format(result, this.getClass().getSimpleName(), this.getLength(), this.getWeight(), this.getInfestation() );
|
2026-03-18 15:19:10 +01:00
|
|
|
}
|
|
|
|
|
}
|