


版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、import java.io.Serializable 。public class Course implements Serializableprivate String courseName 。private int courseGrade 。Course(> courseName=null 。 courseGrade=0。public void setCourseNameValue(String ss> this.courseName=ss。public void setCourseGradeValue(int dd> this.courseGrade=dd。publi
2、c String getCourseNameValue(> return this.courseName 。public int getCourseGradeValue(> return this.courseGrade 。public boolean equals(Object o> if (o = null> return false 。 else if (o instanceof Course> Course rec = (Course> o 。if (this.courseName.equals(rec.getCourseNameValue(>
3、>> return true 。 return false 。 import java.io.Serializable 。import java.util.Arrays 。import java.util.LinkedList 。import java.util.List 。public class Student implements Serializable, Comparable private String studentName 。private int studentId 。/private int studentCourseAmount=4 。 private Lin
4、kedList courseList 。Student(>studentName=null 。 studentId=0 。 courseList=new LinkedList(> 。 public void setStudentNameValue(String name>/ 确定学生名称 this.studentName=name。public void setStudentIdValue(int id>/ 确定学生学号 this.studentId=id 。public void setStudentCourseList(LinkedList list>/ 传入
5、课程链 list this.courseList=list 。/ System.out.println(" 例: 0916 张磊 语文 98 数学 67"> 。public void setCourseGrade(Object o>/ 将与学科 o 同名的学科的成绩改为 o 的成绩 for(int i=0 。 i<this.courseList.size(> 。 i+>Course obj=new Course(> 。 obj=(Course> this.courseList.get(i> 。 if(obj.equals(o&
6、gt;>Course res=(Course> o。 obj.setCourseGradeValue(res.getCourseGradeValue(>>。 public String getStudentNameValue(>/ 取得学生姓名 return this.studentName 。public int getStudentId(>/ 取得学生学号 return this.studentId 。public LinkedList getstudentCourseList(>/ 得到成绩链的首地址 return this.courseList
7、 。public long getStudentCourseGrade(Course o>/ 取得与 o 同名的成绩值,尚有错误 long temp = 0 。List courTemp=this.getstudentCourseList(> 。 Course obj 。/System.out.println(courTemp.indexOf(o>> 。int i=courTemp.indexOf(o> 。 obj=(Course> courTemp.get(i> 。 temp=obj.getCourseGradeValue(> 。return
8、temp 。public boolean equals(Object o> / 判定两个对象是否相同,姓名或学号相同 if (o = null> return false 。else if (o instanceof Student> Student rec = (Student> o 。System.out.println(rec.getStudentNameValue(>> 。if (this.studentName.equals(rec.getStudentNameValue(>> | this.studentId=rec.getStude
9、ntId(>> return true 。return false 。public int compareTo(Object O> Student obj=(Student> O 。 int thisSum=0 。for(int i=0 。 i<this.courseList.size(> 。 i+>Course cour=(Course> this.courseList.get(i> 。 thisSum += cour.getCourseGradeValue(> 。 int OSum=0 。 for(int i=0 。 i<o
10、bj.getstudentCourseList(>.size(> 。 i+>Course cour=(Course> obj.getstudentCourseList(>.get(i> 。OSum += cour.getCourseGradeValue(> 。 if(thisSum<OSum> return -1 。 if(thisSum>OSum> return 1 。 return 0 。import java.awt.Color 。import java.awt.Font 。import java.io.BufferedR
11、eader 。/import java.util.* 。import java.io.FileNotFoundException 。import java.io.FileOutputStream 。import java.io.FileWriter 。import java.io.IOException 。import java.io.InputStreamReader 。import java.io.PrintWriter 。import java.io.Serializable 。import java.sql.Date 。import java.text.DecimalFormat 。i
12、mport java.text.NumberFormat 。import java.util.Arrays 。import java.util.LinkedList 。import java.util.List 。import java.util.Scanner 。import java.util.* 。import org.jfree.chart.ChartFactory 。import org.jfree.chart.ChartFrame 。import org.jfree.chart.ChartUtilities 。import org.jfree.chart.JFreeChart 。i
13、mport org.jfree.chart.axis.CategoryAxis 。import org.jfree.chart.axis.NumberAxis 。import org.jfree.chart.labels.StandardPieSectionLabelGenerator 。import org.jfree.chart.plot.CategoryPlot 。import org.jfree.chart.plot.PiePlot 。import org.jfree.chart.plot.PlotOrientation 。import org.jfree.chart.title.Te
14、xtTitle 。import org.jfree.data.category.DefaultCategoryDataset 。import org.jfree.data.general.DefaultPieDataset 。public class Teacher private String teacherName 。private List studentList 。Teacher(>teacherName=null 。 studentList=new LinkedList(> 。public void setTeacherName(String name> this.
15、teacherName=name。public void setStudentList(LinkedList list> this.studentList=list 。public String getTeacherName(>return this.teacherName 。public List getStudentList(>return this.studentList 。public void addStudent(Object o>/ 添加学生 o/Date date=new Date(0> 。if(o!=null && (o inst
16、anceof Student>> studentList.add(o> 。/* String s = null 。try FileWriter fw = new FileWriter("manager.log", true> 。PrintWriter log = new PrintWriter(fw> 。 log.println(""> 。/ log.println(this.getTeacherName(>> 。Student stu=(Student> o 。 log.println("
17、 添加学生 "> 。log.println(" 学号: "+stu.getStudentId(>+" "+" 姓名 : "+stu.getStudentNameValue(>> 。 log.println("="+new Date( 0>+"="> 。log.flush(> 。log.close(> 。 catch (IOException e> e.printStackTrace(> 。*/public void toAdd
18、Student(Scanner tempCourse>System.out.println(" 输入要添加学生的学号,姓名,各科名称及成绩 以空格分开 ">。System.out.println(" 例: 09001 朱良 语文 23 数学 45 英语 78"> 。 InputStreamReader isr = new InputStreamReader(System.in> 。BufferedReader br = new BufferedReader(isr> 。String s = null 。try s = br.
19、readLine(> 。 tempCourse=new Scanner(s> 。 Student stu = new Student(> 。 if(tempCourse.hasNextInt(>> int stuId = tempCourse.nextInt(> 。 if(tempCourse.hasNext(>>String stuName = tempCourse.next(> 。 stu.setStudentNameValue(stuName>。 stu.setStudentIdValue(stuId> 。LinkedLi
20、st objList=new LinkedList(> 。String courseName=null 。int courseGrade=0 。Course objCourse。while(tempCourse.hasNext(> | tempCourse.hasNextInt(>>courseName=tempCourse.next(> 。courseGrade=tempCourse.nextInt(> 。 objCourse=new Course(> 。objCourse.setCourseNameValue(courseName>。objC
21、ourse.setCourseGradeValue(courseGrade>。 objList.add(objCourse> 。stu.setStudentCourseList(objList> 。int k=0 。for(int j=0 。 j<this.studentList.size(> 。 j+>Student cc=(Student> this.studentList.get(j> 。 if(cc.getStudentId(>=stu.getStudentId(>> k+。if(k=0>this.addStude
22、nt(stu>。System.out.println(" 添加成功 "> 。elseSystem.out.println(" 已存在该学号 "> 。 this.toAddStudent(tempCourse> 。elseSystem.out.println(" 错误输入 "> 。 this.toAddStudent(tempCourse> 。else System.out.println(" 错误输入 "> 。 this.toAddStudent(tempCourse>
23、; 。 catch (IOException e> e.printStackTrace(> 。 finallytry br.close(>。 catch (IOException e> e.printStackTrace(> 。 public void removeStudent(int id>/ 删除学号与 id 相同的对象 int index=-1 。for(int i=0 。 i<this.studentList.size(> 。 i+> Student temp=(Student> this.studentList.get(i
24、> 。 if(temp.getStudentId(> = id> index=i 。if(index != -1>Student stu=(Student> this.studentList.get(index> 。 this.studentList.remove(index> 。System.out.println(" 删除成功 "> 。/*String s = null 。 try FileWriter fw = new FileWriter("manager.log", true> 。 Prin
25、tWriter log = new PrintWriter(fw> 。 log.println(""> 。/log.println(this.getTeacherName(>> 。 / Student stu=(Student> o 。 log.println(" 删除学生 "> 。log.println(" 学号: "+stu.getStudentId(>+" "+" 姓名 : "+stu.getStudentNameValue(>> 。
26、log.println("="+new Date(0>+"="> 。log.flush(> 。 log.close(> 。 catch (IOException e> e.printStackTrace(> 。 */ else System.out.println(" 不存在该学生 "> 。 this.toRemoveStudent(> 。 public void toRemoveStudent(>System.out.println(" 输入要删除学生的学号 "
27、;> 。InputStreamReader isr = new InputStreamReader(System.in> 。 BufferedReader br = new BufferedReader(isr> 。 String s = null 。 try s = br.readLine(> 。Scanner tempCourse=new Scanner(s>。if(tempCourse.hasNextInt(>>int stuId = tempCourse.nextInt(> 。 this.removeStudent(stuId> 。
28、else System.out.println(" 错误输入 "> 。 this.toRemoveStudent(> 。/ int stuId = tempCourse.nextInt(> 。/ this.removeStudent(stuId> 。 catch (IOException e> e.printStackTrace(> 。 finallytry br.close(>。 catch (IOException e> e.printStackTrace(> 。public void changeStudent(S
29、tudent o>/ 与 o 学号或姓名一样的学生对象用 o 替代 int index=0 。for(int i=0 。 i<this.studentList.size(> 。 i+>Student temp=(Student> this.studentList.get(i> 。 if(temp.getStudentId(> = o.getStudentId(> | temp.getStudentNameValue(>.equals(o.getStudentNameValue(>>>index=i 。 break。Stud
30、ent stu=(Student> this.studentList.get(index> 。 this.studentList.set(index,o> 。/* String s = null 。try FileWriter fw = new FileWriter("manager.log", true> 。PrintWriter log = new PrintWriter(fw> 。log.println(""> 。/log.println(this.getTeacherName(>> 。/Studen
31、t stu=(Student> o 。log.println(" 修改学生信息 "> 。log.println(" 学号: "+stu.getStudentId(>+" "+" 姓名 : "+stu.getStudentNameValue(>> 。 log.println("="+new Date(0>+"="> 。log.flush(> 。log.close(> 。 catch (IOException e> e.
32、printStackTrace(> 。*/public void toChangeStudent(>System.out.println(" 输入要修改的学生的学号,姓名,各科名称及成绩 以空格分开 ">。System.out.println(" 例: 09001 朱良 语文 23 数学 45 英语 78"> 。InputStreamReader isr = new InputStreamReader(System.in> 。BufferedReader br = new BufferedReader(isr> 。St
33、ring s = null 。try s = br.readLine(> 。Scanner tempCourse=new Scanner(s>。Student stu = new Student(> 。int stuId = tempCourse.nextInt(> 。String stuName = tempCourse.next(> 。 stu.setStudentNameValue(stuName>。 stu.setStudentIdValue(stuId> 。 LinkedList objList=new LinkedList(> 。 S
34、tring courseName=null 。int courseGrade=0 。Course objCourse。 while(tempCourse.hasNext(> | tempCourse.hasNextInt(>> courseName=tempCourse.next(> 。courseGrade=tempCourse.nextInt(> 。 objCourse=new Course(> 。objCourse.setCourseNameValue(courseName>。 objCourse.setCourseGradeValue(cour
35、seGrade>。 objList.add(objCourse> 。 stu.setStudentCourseList(objList> 。this.changeStudent(stu>。 catch (IOException e> e.printStackTrace(> 。 finallytry br.close(>。 catch (IOException e> e.printStackTrace(> 。public void searchStudentById(/ 查找学号为 id 的学生的信息 学号,姓名,各科成绩)System.ou
36、t.println(" 输入学号: "> 。Scanner sc = new Scanner(System.in> 。int id = sc.nextInt(> 。int index=0 。for(int i=0 。 i<this.studentList.size(> 。 i+>Student temp=(Student> this.studentList.get(i> 。 if(temp.getStudentId(> = id>index=i 。Student sss=(Student> this.stud
37、entList.get(index> 。System.out.println(" 姓名: "+sss.getStudentNameValue(>+" "> 。System.out.println(" 学号: "+sss.getStudentId(>+" "> 。 LinkedList cour=new LinkedList(> 。 cour=sss.getstudentCourseList(> 。for(int i=0 。 i<cour.size(> 。 i+&
38、gt;Course tempCourse=new Course(> 。 tempCourse=(Course> cour.get(i> 。 System.out.println(tempCourse.getCourseNameValue(>+":"+tempCourse.getCourseGradeValue(>+" "> 。public void courseAverage(>/ 计算单科平均分System.out.println(" 输入课程名 "> 。Course o = new
39、Course(> 。Scanner sc = new Scanner(System.in> 。String ss=sc.next(> 。o.setCourseNameValue(ss>。long sum=0 。for(int i=0 。 i<this.studentList.size(> 。 i+>Student tempStu=(Student> this.studentList.get(i> 。sum=sum+tempStu.getStudentCourseGrade(o> 。double aver = (double> s
40、um/this.studentList.size(> 。 System.out.println(aver> 。public void makeOrderByGrades(>/ 将学生信息按总成绩从小到大打印到控制台上Object stuArray=this.studentList.toArray(> 。Arrays.sort(stuArray> 。for(int i=0 。 i<stuArray.length 。 i+>Student tempStu=(Student> stuArrayi 。 System.out.print(tempStu.g
41、etStudentId(>+" "> 。 System.out.print(tempStu.getStudentNameValue(>+" "> 。 LinkedList cour=new LinkedList(> 。 cour=tempStu.getstudentCourseList(> 。for(int j=0 。 j<cour.size(> 。 j+>Course tempCourse=new Course(> 。 tempCourse=(Course> cour.get(j>
42、 。 System.out.print(tempCourse.getCourseNameValue(>+" "+tempCourse.getCourseGradeValue(>+" "> 。System.out.println(> 。public void toClear(>this.studentList.clear(> 。String s = null 。try FileWriter fw = new FileWriter("manager.log", true> 。PrintWriter
43、 log = new PrintWriter(fw> 。log.println(""> 。log.println(this.getTeacherName(>> 。/Student stu=(Student> o 。log.println(" 删除全部学生信息 "> 。log.println("="+new Date(0>+"="> 。log.flush(> 。log.close(> 。 catch (IOException e> e.printSta
44、ckTrace(> 。public void PieChart(>/ 饼形图/ int count=scoreAna(> 。DefaultPieDataset pieDataset = new DefaultPieDataset(> 。int count = 0,0,0,0,0 。/ for(>System.out.println(" 输入课程名 "> 。Course o = new Course(> 。Scanner sc = new Scanner(System.in> 。String ss=sc.next(> 。o
45、.setCourseNameValue(ss>。/ long sum=0 。for(int i=0 。 i<this.studentList.size(> 。 i+>Student tempStu=(Student> this.studentList.get(i> 。int temp=(int> tempStu.getStudentCourseGrade(o> 。 if(0<=temp&& temp<60> count0+ 。/ 不及格人数 if(60<=temp&& temp<70&
46、gt; count1+ 。/ 及格人数if(70<=temp&& temp<80> count2+ 。/ 中等人数 if(80<=temp&& temp<=100> count3+ 。/ 良好人数if(90<=tempStu.getStudentCourseGrade(o>&& tempStu.getStudentCourseGrade(o><=100>count4+ 。/ 优秀人数/ for(int j=0 。 j<count.length 。 j+>/ System
47、.out.println(countj> 。/ pieDataset.setValue(”优秀 ”,countO>。pieDataset.setValue(” 良好",count1> 。pieDataset.setValue("中等",count2>。pieDataset.setValue("及格",count3> 。pieDataset.setValue("不及格",count4> 。JFreeChart chart = ChartFactory.createPieChart3D(&qu
48、ot; 饼形图 ",pieDataset, true, false, false>。*A start*/设置标题字体样式chart.getTitle(>.setFont(new Font("黑体",Font.BOLD,20>> 。/设置饼状图里描述字体样式PiePlot piePlot= (PiePlot> chart.getPlot(> 。 piePlot.setLabelFont(new Font(” 黑体",Font.BOLD,1O>> 。/设置显示百分比样式piePlot.setLabelGener
49、ator(new StandardPieSectionLabelGenerator( ("0(2>">, NumberFormat.getNumberInstance(>, new DecimalFormat("0.00%">>> 。/设置统计图背景 piePlot.setBackgroundPaint(Color.white> 。/设置图片最底部字体样式chart.getLegend(>.setltemFont(new Font("黑体",Font.BOLD,1O>> 。*
50、A end*try ChartUtilities.writeChartAsPNG(new FileOutputStream("pieChart.jpg">, chart,400, 300> 。catch (FileNotFoundException e> e.printStackTrace(> 。 catch (IOException e> e.printStackTrace(> 。final ChartFrame preview = new ChartFrame(" 学生成绩情况 ",chart> 。 prev
51、iew.pack(> 。preview.setVisible(true> 。/ LabelFramePieChart app = new LabelFramePieChart(> 。/ app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE> 。/ app.setSize( 450,350 > 。/app.setVisible( true > 。 import java.io.* 。import java.util.Arrays 。import java.util.LinkedList 。import java.u
52、til.List 。import java.util.Scanner 。import javax.swing.text.html.HTMLDocument.Iterator 。 public class Running public void start(> throws IOExceptionTeacher objTeacher=new Teacher(>。Running run=new Running(> 。try ObjectInputStream is = new ObjectInputStream(new FileInputStream("TestObje
53、ctIO.txt">> 。LinkedList tempList = (LinkedList> is.readObject(> 。 / 从流中读取 List 的数据objTeacher.setStudentList(LinkedList> tempList> 。Object stuArray=tempList.toArray(> 。is.close(> 。 catch (FileNotFoundException e> e.printStackTrace(> 。 catch (IOException e> e.printStackTrace(>
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 柳州市初三三模数学试卷
- 网络安全与动物药品支付风险关联研究报告
- 南宫丰翼小升初数学试卷
- 老版高一数学试卷
- 南京二年级期中数学试卷
- 车辆动态检测计量标准探讨
- 2025浙江宁波市北仑区大榭街道社区卫生服务中心招聘编外工作人员1人考试备考题库及答案解析
- 2025年网络空间安全技术工程师资格认证考试试卷及答案
- 2025北京联合大学招聘工作人员21人(第二批)考试备考题库及答案解析
- 2025浙江温州市白鹿文化演艺发展有限公司面向社会招聘1名工作人员笔试模拟试题及答案解析
- 学校维修维护合同模板
- 设备安装应急应对预案
- 民事诉讼委托书
- 初中一年级思维逻辑训练数学题300道附答案
- 医疗机构医疗废物暂存间消毒记录表
- JT-T-617.6-2018危险货物道路运输规则第6部分:装卸条件及作业要求
- DL-T5372-2017水电水利工程金属结构与机电设备安装安全技术规程
- 新时代高职英语(基础模块)Unit1 -2
- 糖尿病患者延续性护理的研究进展
- FZT 95032-2021 长环蒸化机行业标准
- 2023年临沧市市级单位遴选(选调)工作人员考试真题
评论
0/150
提交评论