48 lines
701 B
D
48 lines
701 B
D
module stats;
|
|
|
|
interface Stat
|
|
{
|
|
void accumulate(double x);
|
|
void postprocess();
|
|
double result();
|
|
}
|
|
|
|
class Min : Stat
|
|
{
|
|
private double min = double.max;
|
|
|
|
void accumulate(double x)
|
|
{
|
|
if (x < min)
|
|
{
|
|
min = x;
|
|
}
|
|
}
|
|
|
|
void postprocess() {} // Ничего не делать
|
|
|
|
double result()
|
|
{
|
|
return min;
|
|
}
|
|
}
|
|
|
|
class Max : Stat
|
|
{
|
|
private double max = double.min_normal;
|
|
|
|
void accumulate(double x)
|
|
{
|
|
if (x > max)
|
|
{
|
|
max = x;
|
|
}
|
|
}
|
|
|
|
void postprocess() {} // Ничего не делать
|
|
|
|
double result()
|
|
{
|
|
return max;
|
|
}
|
|
}
|