This commit is contained in:
Simoes Lukas
2025-03-04 13:22:24 +01:00
parent 422a41d232
commit 9441c8978a
16 changed files with 170 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
public class MoyenneV1 {
private double moyenne;
private int compteur;
public MoyenneV1() {
this.moyenne = 0;
this.compteur = 0;
}
public double add(byte n) {
this.compteur++;
return this.moyenne += n;
}
public double add(short n) {
this.compteur++;
return this.moyenne += n;
}
public double add(int n) {
this.compteur++;
return this.moyenne += n;
}
public double add(long n) {
this.compteur++;
return this.moyenne += n;
}
public double add(float n) {
this.compteur++;
return this.moyenne += n;
}
public double add(double n) {
this.compteur++;
return this.moyenne += n;
}
public double getAverage() {
return this.moyenne / this.compteur;
}
public static void main(String[] args) {
MoyenneV1 m = new MoyenneV1();
m.add(2);
m.add(5.4);
m.add(547L);
System.out.println(m.getAverage());
}
}