⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fuction.java

📁 JAVA学生考试成绩分析程序
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package studentscore;import java.util.*;/** * * 基本数据处理类 * @author Conupe Fox */public class Fuction {    /**查找方法*/    public static boolean find(ArrayList<Classes> al, Classes c){        Iterator it = al.iterator();        while(it.hasNext()){            Classes cs = (Classes)it.next();            if(cs.equels(c))                return true;        }        return false;    }    public static boolean find(ArrayList<Lesson> al, Lesson l){        Iterator it = al.iterator();        while(it.hasNext()){            Lesson ls = (Lesson)it.next();            if(ls.equals(l))                return true;        }        return false;    }    //未使用    public static boolean find(ArrayList<Classes> al, Student st){        Iterator itClass = al.iterator();        while(itClass.hasNext()){            Classes cs = (Classes)itClass.next();            Iterator itStu = cs.getStudentList().iterator();            while(itStu.hasNext()){                Student stu = (Student)itStu.next();                if(stu.equals(st))                    return true;            }        }        return false;    }       //按学号查找    public static Student find(ArrayList<Classes> al, long id){        Iterator itClass = al.iterator();        while(itClass.hasNext()){            Classes cs = (Classes)itClass.next();            Iterator itStu = cs.getStudentList().iterator();            while(itStu.hasNext()){                Student stu = (Student)itStu.next();                if(stu.getId() == id)                    return stu;            }        }        return null;    }    //获取班级    public static Classes getClasses(ArrayList<Classes> al, Student st){        Iterator itClass = al.iterator();        while(itClass.hasNext()){            Classes cs = (Classes)itClass.next();            Iterator itStu = cs.getStudentList().iterator();            while(itStu.hasNext()){                Student stu = (Student)itStu.next();                if(stu.equals(st))                    return cs;            }        }        return null;    }        //获取课程    public static Lesson getLesson(Student stu, Lesson l){        Iterator itLesson = stu.getLesson().iterator();        while(itLesson.hasNext()){            Lesson lesson = (Lesson)itLesson.next();            if(lesson.equals(l)){                return lesson;            }        }        return null;        }            /**新增方法*/    public static boolean add(ArrayList<Classes> al, Classes c){        if(find(al,c)){            return false;        }        else{            al.add(c);            return true;        }    }    public static boolean add(ArrayList<Lesson> al, Lesson l){        if(find(al,l)){            return false;        }        else{            al.add(l);            return true;        }    }    //未使用    public static boolean add(ArrayList<Classes> al, Classes c, Student st){        if(find(al,st)){            return false;        }        else{            c.addStudent(st);            return true;        }    }        /** 移除方法 */    //移除班级    public static void remove(ArrayList<Classes> al, Classes c){       al.remove(c);    }    //移除课程    public static void remove(ArrayList<Classes> alClass, ArrayList<Lesson> alLesson, Lesson l){        alLesson.remove(l);        //遍历所有学生课程        Iterator itClass = alClass.iterator();        while(itClass.hasNext()){            Classes cs = (Classes)itClass.next();            Iterator itStu = cs.getStudentList().iterator();            while(itStu.hasNext()){                Student stu = (Student)itStu.next();                Iterator itLesson = stu.getLesson().iterator();                while(itLesson.hasNext()){                    Lesson ls = (Lesson)itLesson.next();                    if(ls.equals(l)){                        itLesson.remove();                        break;                    }                }            }        }    }    //移除学生(未使用)    public static void remove(ArrayList<Classes> al, Classes c, Student st){        c.removeStudent(st);    }        public static boolean modify(ArrayList<Classes> alClass, ArrayList<Lesson> alLesson, Lesson l, Lesson lNew){        //修改课程列表中的课程信息        l.setName(lNew.getName());        l.setId(lNew.getId());        l.setHours(lNew.getHours());        l.setPoints(lNew.getPoints());        //遍历所有学生课程        Iterator itClass = alClass.iterator();        while(itClass.hasNext()){            Classes cs = (Classes)itClass.next();            Iterator itStu = cs.getStudentList().iterator();            while(itStu.hasNext()){                Student stu = (Student)itStu.next();                Lesson ls = Fuction.getLesson(stu, l);                if(ls != null){                    //修改学生课程列表中的信息                    ls.setHours(lNew.getHours());                    ls.setId(lNew.getId());                    ls.setName(lNew.getName());                    ls.setPoints(lNew.getPoints());                }            }        }        return true;   }            }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -