A lot of things.
- Change tests directory location. - Fix Merlu CSV UTF8 encoding. - Make classes for ParasitesPeru2021.csv Parsing.
This commit is contained in:
60
src/ecoparasite/population/PopulationArgInterval.java
Normal file
60
src/ecoparasite/population/PopulationArgInterval.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package ecoparasite.population;
|
||||
|
||||
public class PopulationArgInterval {
|
||||
|
||||
private Double min;
|
||||
private Double max;
|
||||
|
||||
private Double mean;
|
||||
|
||||
public PopulationArgInterval(Double min, Double max, Double mean) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.mean = mean;
|
||||
}
|
||||
public PopulationArgInterval(Double min, Double max) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.mean = ( this.max + this.min ) / 2;
|
||||
}
|
||||
|
||||
public Double getMin() {
|
||||
return this.min;
|
||||
}
|
||||
public Double getMax() {
|
||||
return this.max;
|
||||
}
|
||||
public Double getMean() {
|
||||
return this.mean;
|
||||
}
|
||||
|
||||
public Double transformToDouble(){
|
||||
if( this.min == this.max )
|
||||
return this.min;
|
||||
return this.mean;
|
||||
}
|
||||
|
||||
public static PopulationArgInterval fromString( String rawValue ){
|
||||
|
||||
if( rawValue.contains( "±" ) ){ // Plus ou moins.
|
||||
|
||||
String[] numbers = rawValue.split("±");
|
||||
Double mean = Double.parseDouble(numbers[0].trim());
|
||||
Double interval = Double.parseDouble(numbers[1].trim());
|
||||
return new PopulationArgInterval(mean - interval, mean + interval, mean);
|
||||
|
||||
} else if( rawValue.contains( "-" ) ){ // Entre.
|
||||
|
||||
String[] numbers = rawValue.split("-");
|
||||
Double min = Double.parseDouble(numbers[0].trim());
|
||||
Double max = Double.parseDouble(numbers[1].trim());
|
||||
return new PopulationArgInterval(min, max);
|
||||
|
||||
} else {
|
||||
Double number = Double.parseDouble(rawValue);
|
||||
return new PopulationArgInterval(number, number);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user