Added StatsCalculator and Periode Class
This commit is contained in:
+4
-19
@@ -50,25 +50,10 @@ public class Grootheid
|
||||
}
|
||||
|
||||
//Methods
|
||||
public void calculateMaxMinAvg(ArrayList<Double> laatste24uur){
|
||||
double tempMax = 0;
|
||||
double tempAvg = 0;
|
||||
double tempMin = laatste24uur.get(0);
|
||||
|
||||
for(double ms : laatste24uur){
|
||||
if(ms > tempMax){
|
||||
tempMax = ms;
|
||||
}
|
||||
if(ms < tempMin){
|
||||
tempMin = ms;
|
||||
}
|
||||
tempAvg += ms;
|
||||
}
|
||||
tempAvg /= laatste24uur.size();
|
||||
|
||||
setMax(tempMax);
|
||||
setMin(tempMin);
|
||||
setAvg(tempAvg);
|
||||
public void calculateMaxMinAvg(ArrayList<Double> array){
|
||||
setMax( StatisticsCalculator.max(array) );
|
||||
setMin( StatisticsCalculator.min(array) );
|
||||
setAvg( StatisticsCalculator.avg(array) );
|
||||
}
|
||||
|
||||
public void updateRecent(Measurement measurement1){
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
public class Periode
|
||||
{
|
||||
public Periode()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class StatisticsCalculator {
|
||||
|
||||
public static double max(ArrayList<Double> array)
|
||||
{
|
||||
double max = 0;
|
||||
|
||||
for(double waarde : array){
|
||||
if(waarde > max){
|
||||
max = waarde;
|
||||
}
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
public static double min(ArrayList<Double> array)
|
||||
{
|
||||
double min = array.get(0);
|
||||
|
||||
for(double waarde : array){
|
||||
if(waarde < min){
|
||||
min = waarde;
|
||||
}
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
public static double avg(ArrayList<Double> array)
|
||||
{
|
||||
double avg = 0;
|
||||
|
||||
for(double waarde : array){
|
||||
avg += waarde;
|
||||
}
|
||||
avg /= array.size();
|
||||
return avg;
|
||||
}
|
||||
|
||||
public static Periode langsteDroogstePeriode(ArrayList<Double> array)
|
||||
{
|
||||
Periode periode = new Periode();
|
||||
|
||||
|
||||
return periode;
|
||||
}
|
||||
|
||||
public static Periode langsteDroogstePeriodeMetMax(ArrayList<Double> array, int maxNeerslag)
|
||||
{
|
||||
Periode periode = new Periode();
|
||||
|
||||
|
||||
return periode;
|
||||
}
|
||||
|
||||
public static Periode langsteRegenPeriode(ArrayList<Double> array)
|
||||
{
|
||||
Periode periode = new Periode();
|
||||
|
||||
|
||||
return periode;
|
||||
}
|
||||
|
||||
public static double meesteRegenAchterElkaar(ArrayList<Double> array)
|
||||
{
|
||||
double regenHoeveelheid = 0;
|
||||
|
||||
|
||||
return regenHoeveelheid;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user