Main类:在main方法中,调用constructStudentList方法构建一个Worker对象链表,调用computeAverageScore方法计算一个班级的平均分并输出到屏幕。 根据要求,编写Student类和StudentList类。
Student类的编程要求如下:
成员变量包括:学生姓名(String name)、班级编码(String classCode)、分数(int score)
根据程序需求编写构造方法。
根据程序需求编写set和get方法。
StudentList类的编程要求如下:
根据程序需求编写构造方法。
constructStudentList方法:调用readInStudent方法读入多个学生信息,将Student对象添加到链表中,构建一个Student对象链表,最后返回链表。
readInStudent方法:使用scanner从键盘读入一个学生的姓名、班级和分数,构建一个Student对象并返回。
computeAverageScore(List list)方法:遍历链表,累加链表中所有学生人数和总分数,计算出某个班级平均分并返回。
函数接口定义:
StudentList类的编程要求如下:
List<Student> constructStudentList();
Student readInStudent();
double computeAverageScore(List<Student> list);
import java.util.*;
public class Main {
public static void main(String[] args) {
StudentList sl=new StudentList();
List<Student> list