package day11;
public class TestSchoo1 {
public static void main(String[] args) {
Student stu1 = new Student();
stu1.name = "tom";
stu1.age=20;
stu1.sex='男';
stu1.score=99.0;
Student stu2 = new Student();
stu2.name = "tom";
stu2.age=20;
stu2.sex='男';
stu2.score=77.0;
Student stu3 = new Student();
stu3.name = "tom";
stu3.age=20;
stu3.sex='男';
stu3.score=77.0;
Teacher t1 = new Teacher();
double result = t1.totalSocre(stu1.score, stu2.score);
System.out.println(result);
double[] scores = {stu1.score,stu2.score,stu3.score};
double studenl = t1.totalSocre(scores);
System.out.println(studenl);
}
}
class Student{
String name;
int age;
char sex;
double score;
}
class Teacher{
String name;
int age;
char sex;
double salry;
public double totalSocre(double score1, double score2) {
return score1 + score2;
}
public double totalSocre(double[] scores) {
//循环
double sum = 0.0;
for (int i = 0; i < scores.length; i++) {
sum += scores[i];
}
return sum;
}
}