34 lines
673 B
Java
34 lines
673 B
Java
public class absMoyenne2 extends Number{
|
|
private double total;
|
|
private int nbValeur;
|
|
public Moyenne2(){
|
|
this.nbValeur = 0;
|
|
this.total = 0;
|
|
}
|
|
public void add(Number valeur){
|
|
this.nbValeur ++;
|
|
this.total += valeur.doubleValue();
|
|
}
|
|
public double getAverage(){
|
|
return this.total/this.nbValeur;
|
|
}
|
|
/*@Override
|
|
public double doubleValue() {
|
|
return 1;
|
|
}
|
|
@Override
|
|
public int intValue() {
|
|
return (int) this.total;
|
|
}
|
|
|
|
@Override
|
|
public long longValue() {
|
|
return (long) this.total;
|
|
}
|
|
|
|
@Override
|
|
public float floatValue() {
|
|
return (float) this.total;
|
|
}*/
|
|
}
|