某团笔试题

统计考试的通过率最低的n个课程和通过率

比如:

老师A教授了 英语1、数学1, 英语1通过率是70%,数学1通过率是89%

老师B教授了 英语2、数学2, 英语2通过率是75%,数学2通过率是65%

通过率最低的2个课程是 英语1和数学2

返回 英语1 通过率70%

数学2 通过率65%

注意:1个老师可能任多门课,学生可能参加多门课的多场考试

---------------------请完成以下代码----------------------

/**

  • @param n 需要统计的通过率最低的n个课程
  • @param resultList 本学年所有学生的所有考试的结果
  • @return 考试通过率最低的课程及相关的通过率

*/
public static Map<Course, Float> calculate(int n, List resultList) {

}

-----------以下是相关对象定义----------

//课程定义
public class Course {
private int id;
// 课程名称
private String name;
// 任课老师
private Teacher teacher;

public Course(int id, String name, Teacher teacher) {
this.id = id;
this.name = name;
this.teacher = teacher;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Teacher getTeacher() {
return teacher;
}

public void setTeacher(Teacher teacher) {
this.teacher = teacher;
}
}

//学生定义
public class Student {
private int id;
// 学生姓名
private String name;
// 性别
private int sex;
// 生日
private Date birth;

public Student(int id, String name, int sex, Date birth) {
this.id = id;
this.name = name;
this.sex = sex;
this.birth = birth;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getSex() {
return sex;
}

public void setSex(int sex) {
this.sex = sex;
}

public Date getBirth() {
return birth;
}

public void setBirth(Date birth) {
this.birth = birth;
}
}

//老师定义
public class Teacher {
private int id;
// 老师姓名
private String name;
// 性别
private int sex;

public Teacher(int id, String name, int sex) {
this.id = id;
this.name = name;
this.sex = sex;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getSex() {
return sex;
}

public void setSex(int sex) {
this.sex = sex;
}
}

//考试定义

public class Exam {
// 开始开始时间
private Date beginTime;
// 考试结束时间
private Date endTime;
// 考试课程
private Course course;
// 满分
private int fullScore;
// 及格分
private int passScore;

public Exam(Date beginTime, Date endTime, Course course, int fullScore, int passScore) {
this.beginTime = beginTime;
this.endTime = endTime;
this.course = course;
this.fullScore = fullScore;
this.passScore = passScore;
}

//… 省去 getter 和 setter 方法
}

//考试结果定义
public class ExamResult {
// 考试信息
private Exam exam;
// 参加考试的学生
private Student student;
// 考试成绩
private int score;

public ExamResult(Exam exam, Student student, int score) {
this.exam = exam;
this.student = student;
this.score = score;
}

public Exam getExam() {
return exam;
}

public void setExam(Exam exam) {
this.exam = exam;
}

public Student getStudent() {
return student;
}

public void setStudent(Student student) {
this.student = student;
}

public int getScore() {
return score;
}

public void setScore(int score) {
this.score = score;
}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值