Files
ecoparasite-data-analyse/src/ecoparasite/poisson/Poisson.java

74 lines
2.0 KiB
Java
Raw Normal View History

package ecoparasite.poisson;
import java.util.HashSet;
/**
* 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.
*/
public class Poisson{
private String specie;
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
* @param specie Une String representant l'espece du poisson
* @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
*/
public Poisson(String specie, Double length, Double weight, Double infestation){
this.specie = specie;
this.length = length;
this.weight = weight;
this.infestation = infestation;
2026-03-18 15:37:18 +01:00
this.fishParts = null;
}
2026-03-18 15:37:18 +01:00
/**
* Getter de l'attribut specie
* @return La string de l'attribut specie
*/
public String getSpecie() {
return specie;
}
2026-03-18 15:37:18 +01:00
/**
* Getter de l'attribut length
* @return Le Double de l'attribut length
*/
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
*/
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
*/
public Double getInfestation() {
return infestation;
}
2026-03-18 15:37:18 +01:00
/**
* Permet d'afficher les informations de notre poisson
* @return La string contenant les informations
*/
@Override
public String toString(){
2026-03-18 15:37:18 +01:00
String result = "[ %5s : %4d mm, %4d g, %4d taux d'infestation ]";
return String.format(result, this.getClass().getSimpleName(), this.getLength(), this.getWeight(), this.getInfestation());
}
}