package average public class AverageClass extends Number private publi

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
package average;
public class AverageClass<T extends Number> {
private T[] t;
public AverageClass(T[] t) {
this.t = t;
}
public double getAverage() {
double sum = 0;
for(int i = 0; i < t.length; i++)
sum += t[i].doubleValue();
return sum / t.length;
}
public boolean sameAverage(AverageClass<?> aob) {
return getAverage() >= aob.getAverage() ? true : false;
}
}