BUT2/DEV/DEV2.1/TP07_Polymorphisme/Q2_Moyenne/Moyenne2.java~
2023-10-23 13:23:36 +02:00

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;
}*/
}