📄 result.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package studentscore;import java.util.Iterator;/** * * Result.java * 结果类 * @author Conupe Fox */public class Result { private float highest; //最高分 private float lowest; //最低分 private float average; //平均分 private int [] scoreList; //分数段人数 private float [] precentage; //分数段百分比 /**构造方法*/ public Result(){ highest = -1; lowest = 101; average = 0; scoreList = new int[5]; precentage = new float[5]; } /** getter */ public float getHighest(){ return highest; } public float getLowest(){ return lowest; } public float getAverage(){ return average; } public int getScoreList(int i){ return scoreList[i]; } public float getPercentage(int i){ return precentage[i]; } public int getMaxScoreList(){ int max = 1; for(int i = 0; i < 5; i++){ max = Math.max(max, this.getScoreList(i)); } return max; } /** setter */ public void setHighest(float score){ this.highest = score; } public void setLowest(float score){ this.lowest = score; } public void setAverage(float score){ this.average = score; } public void setPercentage(int i, float precentage){ this.precentage[i] = precentage; } public void addScoreList(int i){ scoreList[i]++; } public static Result scoreAnalyse(Classes c, Lesson l){ Result rs = new Result(); float sum = 0; Iterator itStu = c.getStudentList().iterator(); while(itStu.hasNext()){ Student stu = (Student)itStu.next(); Lesson ls = Fuction.getLesson(stu, l); if(ls != null){ float score =ls.getScore(); if(score < rs.getLowest()) rs.setLowest(score); if(score > rs.getHighest()) rs.setHighest(score); sum += score; if(score >= 0 && score < 60) rs.addScoreList(0); else if(score >= 60 && score < 70) rs.addScoreList(1); else if(score >= 70 && score < 80) rs.addScoreList(2); else if(score >= 80 && score < 90) rs.addScoreList(3); else rs.addScoreList(4); } } rs.setAverage(sum / c.getStudentList().size()); if(c.getStudentList().size() != 0){ for(int i = 0; i < 5; i++){ rs.setPercentage(i, (float)rs.getScoreList(i) / c.getStudentList().size()); } } return rs; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -