public class Client {
public static void main(String[] args) {
Student[] students = {
new Student(100),
new Student(98),
new Student(72),
};
double average = average(students);
System.out.println(average); // 90.0
}
public static double average(Measurable[] objects) {
double sum = 0;
for (Measurable object : objects) {
sum += object.getValue();
}
int length = objects.length;
return sum / length;
}
}
public class Student implements GetInfo {
private double score;
public Student(double score) {
this.score = score;
}
@Override
public double getValue() {
return this.score;
}
}
public interface Measurable {
double getValue();
}
public interface GetInfo extends Measurable{
}
문제가 좆같은듯 ㅋㅋㅋ 존나 코드 몇개면 충분할거 길게 늘어놓게 만드네
fd
와 감사합니다 ㅠㅠㅠ