实验内容

​1. 根据目前所学课堂内容,用java逐步编程实现下述类图,遵循Java编程规范,并为撰写的类提供相应的Javadoc注释。
2. 在FushiSystem.java中已提供部分辅助函数,该类的其它方法,请按上述类图中的要求全部编程实现,最终保证程序在步骤1-7中的执行中,按要求完成功能。
程序运行时可供用户选择要实现的功能,如下图。(此功能已经给出,无需更改)

步骤1:选择1(addStudentToCatalog方法实现的功能):
添加学生,逐步让用户输入以下内容,包括学生的id 和name,添加成功会提示用户相应信息。

步骤2:选择2(displayStudentCatalog方法实现的功能):
显示学生目录,包括学生的id和name,格式如下:

步骤3:选择3(displayExamPaper方法实现的功能):
根据用户输入的学生id,显示该学生的试卷信息,格式如下:

当用户输入不存在的学生id时,提示错误并请用户重新输入。
如果还未为该学生生成试卷,会提示用户“还没有为该学生生成相应的试卷”。

步骤6:选择6(lookupTotalScore方法实现的功能):
根据用户输入的学生id,显示学生复试试卷的总得分,格式如下:

当用户输入不存在的学生id时,提示错误并请用户重新输入。
如果还未为该学生生成试卷,会提示用户“还没有为该学生生成相应的试卷”。

步骤7:选择7(lookupTestScore方法实现的功能):

  1. 根据用户输入的学生id,显示学生复试试卷的每道题目得分,格式如下:
    当用户输入不存在的学生id时,提示错误并请用户重新输入。
    如果还未为该学生生成试卷,会提示用户“还没有为该学生生成相应的试卷”。

代码资源

这里免费提供主程序的代码实现,和演示视频,其余内容请【点击此处】付费查看

请注意,源码仅供参考,由抄袭导致的任何后果将由读着自行承担!

主程序代码实现:

import TestUtil.TestDataBase;
import TestUtil.TestItem;
import TestUtil.Tests.EnglishTest;
import TestUtil.Tests.MathTest;
import TestUtil.Tests.ProfessionalTest;
import TestUtil.Tests.Test;
​
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.Random;
​
​
public class FushiSystem {private StudentCatalog studentCatalog= new StudentCatalog();private TestDataBase testDataBase = new TestDataBase();public void addStudentToCatalog(String id) throws Exception {BufferedReader br = new BufferedReader(new InputStreamReader(System.in));System.err.print("Student name> ");//下一行输入就是学生的名称Student student = new Student(id, br.readLine());studentCatalog.addStudent(student);}
​public void displayStudentCatalog(){int count = studentCatalog.getNumberOfStudent();for(int i=0;i<count;i++){System.out.println(studentCatalog.getStudent(i));}}
​public void displayExamPaper(String id) throws Exception{Student student = lookupStudent(id);System.out.println(student.getExamPaper());}
​/*** 这个方法是老师实现的,做了些许修改以适应我们的代码* @param id* @throws Exception*/public void generateExamPaper(String id) throws Exception {Student student = lookupStudent(id);if (testDataBase.getNumberOfTests() < 10) {System.err.println("There are less than ten test questions in the test question bank, "+ "and the test paper cannot be generated.");} else {int[] testTypeNums = new int[3];for (String code : testDataBase.getTests().keySet()) {Test test = testDataBase.getTest(code);if (test instanceof EnglishTest) {testTypeNums[0]++;} else if (test instanceof MathTest) {testTypeNums[1]++;} else if (test instanceof ProfessionalTest) {testTypeNums[2]++;}}if (testTypeNums[0] < 3 || testTypeNums[1] < 3 || testTypeNums[2] < 4) {System.err.println("There are not enough English questions or math questions or professional "+ "questions in the test database.");return;}//采用随机生成试卷Random random = new Random();ExamPaper examPaper = new ExamPaper();for (int i = 0; i < testTypeNums.length; i++) {testTypeNums[i] = 0;}int allTestCount = testDataBase.getNumberOfTests();boolean[] testIsChoose = new boolean[allTestCount];while (examPaper.getNumberOfTestItems() < 10) {int target = random.nextInt(allTestCount);Test test = testDataBase.getTest(target);
​if (test instanceof EnglishTest) {if (testTypeNums[0] < 3 && (!testIsChoose[target])) {testTypeNums[0]++;examPaper.addTestItem(new TestItem(test, 0));testIsChoose[target] = true;}} else if (test instanceof MathTest) {if (testTypeNums[1] < 3 && (!testIsChoose[target])) {testTypeNums[1]++;examPaper.addTestItem(new TestItem(test, 0));testIsChoose[target] = true;}} else if (test instanceof ProfessionalTest) {if (testTypeNums[2] < 4 && (!testIsChoose[target])) {testTypeNums[2]++;examPaper.addTestItem(new TestItem(test, 0));testIsChoose[target] = true;}}
​}student.setExamPaper(examPaper);System.out.println("Test papers have been generated for this student!");}}
​/*** 这个方法是老师实现的,做了些许修改以适应我们的代码* @param id*/public void entryScore(String id) throws  Exception{Student student = lookupStudent(id);int index = 1;BufferedReader br = new BufferedReader(new InputStreamReader(System.in));for(TestItem ti:student.getExamPaper().testItems){System.out.println(String.format("The score of item %d is: ",index));int score;while(true) {try {score = Integer.parseInt(br.readLine());break;} catch (Exception e) {e.printStackTrace();}}if (score > 10 || score < 0) {System.err.println("The score of each test is no more than 10 or less than 0. Please re-enter!");} else {ti.setScore(score);}++index;}}
​public void lookupTotalScore(String id) throws Exception{Student student = lookupStudent(id);Double score = student.getExamPaper().getTotalScore();if(score!=null){System.out.println(String.format("The total score of the student is: %f",score));}else {System.err.println("The student doesn't get a test paper yet. Please complete it.");}}
​public void lookupTestScore(String id) throws Exception{Student student = lookupStudent(id);int test_items = student.getExamPaper().getNumberOfTestItems();if(test_items==0){System.err.println("The student doesn't get a test paper yet. Please complete it.");}else {for (int i = 0; i < test_items; i++) {System.out.println(String.format("The score of item %d is:%f", i + 1, student.getExamPaper().getTestItem(i).getScore()));}}}
​private Student lookupStudent(String id) throws Exception{Student student = null;BufferedReader br = new BufferedReader(new InputStreamReader(System.in));while((student = studentCatalog.getStudent(id))==null){System.err.println("Error, current student is not exist!");System.err.print("Student id> ");id = br.readLine();}return student;}
​private void init(){testDataBase.addTest(new EnglishTest("E001", "Translate the following text into English.", 2,"Smooth, fluent and without language problems or wrong words", "C-E"));testDataBase.addTest(new EnglishTest("E002", "Translate the following article content.", 3,"Clear logic and no language problems", "E-C"));testDataBase.addTest(new EnglishTest("E003", "Choose the correct answer based on the content being played.", 3,"Correct answer", "Hearing"));testDataBase.addTest(new EnglishTest("E004", "Translate the following Chinese in English.", 2,"No grammatical errors", "C-E"));testDataBase.addTest(new EnglishTest("E005", "Translate the following English in Chinese.", 2, "Sentence fluent", "E-C"));testDataBase.addTest(new EnglishTest("E006", "Choose the correct answer based on contextual dialogue", 2,"Right", "Hearing"));testDataBase.addTest(new EnglishTest("E007", "Translate the following article content.", 3, "Smooth and fluent", "C-E"));testDataBase.addTest(new EnglishTest("E008", "Translate to Chinese", 3, "Complete translation", "E-C"));testDataBase.addTest(new EnglishTest("E009", "Listen to the dialogue and choose Xiao Ming’s weekend schedule.",3, "Correct answer", "Hearing"));testDataBase.addTest(new EnglishTest("E010", "Translate the following text into English.", 2,"Use the correct words and smooth", "C-E"));
​testDataBase.addTest(new MathTest("M001", "Find the inflection points of the following functions.", 2, "Right","no image", "no"));testDataBase.addTest(new MathTest("M002", "Which of the following series converge?", 3, "Right", "no image", "no"));testDataBase.addTest(new MathTest("M003", "Find the differential equation of the following function.", 3,"Necessary problem-solving process", "no image","The first step is to find the integral. The second step is to find the value of the constant c."));testDataBase.addTest(new MathTest("M004", "Find the angle between the two planes A and B.", 2, "Correct answer","http://image.com/m004", "no"));testDataBase.addTest(new MathTest("M005", "Several extreme points in the figure below.", 3, "Right","http://image.com/m005", "no"));testDataBase.addTest(new MathTest("M006", "Find the inflection points of the following functions.", 2, "Right","no image", "no"));testDataBase.addTest(new MathTest("M007", "Find the differential equation of the following function.", 3,"Clear problem solving process and correct value", "no image","Find the value of the constant b and the differential equation"));testDataBase.addTest(new MathTest("M008", "The area enclosed by the following curve and the coordinate axis is?", 1,"Correct answer", "http://image.com/m008", "no"));testDataBase.addTest(new MathTest("M009", "Find general solutions of differential equations.", 2,"The parameters are correct", "no image", "Find the value of the parameter"));testDataBase.addTest(new MathTest("M010", "Find the function f(x).", 2, "Right", "http://image.com/m009", "no"));
​testDataBase.addTest(new ProfessionalTest("P001", "What are the characteristics of JAVA language?", 1, "Right","Name at least three of the characteristics", "no", "no image"));testDataBase.addTest(new ProfessionalTest("P002","Fill in the following blanks to realize the calculation of the sum of the numbers between 1-200 that are not divisible by 5.",2, "Correct result at run", "Fill in the code in the blank.", "no", "http://image.com/p002"));testDataBase.addTest(new ProfessionalTest("P003", "The time complexity of the algorithm refers to?", 1,"Correct answer", "no", "no", "no image"));testDataBase.addTest(new ProfessionalTest("P004", "The number sequence bai is: 1,1,1,2,3,4,6,...", 3,"Correct result at run", "Calculation formula when filling in n.","int main()\n" + "{int a[21]={0,1,1},i;\n" + " for(i=1;i<21;i++)\n"+ "   if(i<3) printf(\"%d \",a[i]);\n" + "     else printf(\"%d \",______);\n"+ " printf(\"\\n when n is 20:%d\\n\",a[20]);\n" + " return 0;\n" + "}","no image"));testDataBase.addTest(new ProfessionalTest("P005","The design of the database includes two aspects of design content, they are?", 2, "Similar in meaning","no", "no", "no image"));testDataBase.addTest(new ProfessionalTest("P006", "The difference between java and c.", 2,"At least three points", "At least three points", "no", "no image"));testDataBase.addTest(new ProfessionalTest("P007", "The difference between process and thread.", 3,"At least three points", "At least three points", "no", "no image"));testDataBase.addTest(new ProfessionalTest("P008", "The time complexity of the following code is?", 1, "Right","no", "no", "http://image.com/p008"));testDataBase.addTest(new ProfessionalTest("P009", "Benefits of thread pool.", 3, "Can name the key benefits","no", "no", "no image"));testDataBase.addTest(new ProfessionalTest("P010", "Enter 5 numbers to find their maximum and average.", 3,"Correct result at run", "Time complexity cannot exceed n.)", "no", "no image"));
​studentCatalog.addStudent(new Student("2019213001", "吴广胜"));studentCatalog.addStudent(new Student("2019213002", "陈盛典"));studentCatalog.addStudent(new Student("2019213003", "刘子豪"));studentCatalog.addStudent(new Student("2019213004", "仇历"));studentCatalog.addStudent(new Student("2019213005", "郑西泽"));studentCatalog.addStudent(new Student("2019213006", "李梦琪"));studentCatalog.addStudent(new Student("2019213007", "王志"));studentCatalog.addStudent(new Student("2019213008", "张天一"));studentCatalog.addStudent(new Student("2019213009", "周琳琳"));studentCatalog.addStudent(new Student("2019213010", "周爽"));studentCatalog.addStudent(new Student("2019213011", "张涵"));studentCatalog.addStudent(new Student("2019213012", "李依然"));studentCatalog.addStudent(new Student("2019213013", "孟子涛"));studentCatalog.addStudent(new Student("2019213014", "腊志翱"));studentCatalog.addStudent(new Student("2019213015", "张一鸣"));studentCatalog.addStudent(new Student("2019213016", "李华"));studentCatalog.addStudent(new Student("2019213017", "冷子晴"));studentCatalog.addStudent(new Student("2019213018", "金灿"));studentCatalog.addStudent(new Student("2019213019", "朱文杰"));studentCatalog.addStudent(new Student("2019213020", "刘美含"));}
​public static void main(String[] args) throws Exception{FushiSystem fushiSystem = new FushiSystem();fushiSystem.init();
​StringBuilder sb = new StringBuilder();sb.append("[0] quit").append('\n').append("[1] Add Students to the system").append('\n').append("[2] Display All Students").append('\n').append("[3] Display Exam Paper through student identification code").append('\n').append("[4] Generate random retests papers for designed students").append('\n').append("[5] Enter the retests score of the designed student").append('\n').append("[6] Display the total score of the specified student's retest exam").append('\n').append("[7] Display the score of each question of the designated student's re-examination exam");
​System.out.println(sb.toString());System.err.print("choice> ");BufferedReader br = new BufferedReader(new InputStreamReader(System.in));int choice = Integer.parseInt(br.readLine());while(true) {switch (choice) {case 0:{br.close();System.exit(0);break;}case 1:{System.err.print("Student id> ");fushiSystem.addStudentToCatalog(br.readLine());break;}case 2:{fushiSystem.displayStudentCatalog();break;}case 3:{System.err.print("Student id> ");fushiSystem.displayExamPaper(br.readLine());break;}case 4:{System.err.print("Student id> ");fushiSystem.generateExamPaper(br.readLine());break;}case 5:{System.err.print("Student id> ");fushiSystem.entryScore(br.readLine());break;}case 6:{System.err.print("Student id> ");fushiSystem.lookupTotalScore(br.readLine());break;}case 7:{System.err.print("Student id> ");fushiSystem.lookupTestScore(br.readLine());break;}}System.err.print("choice> ");choice = Integer.parseInt(br.readLine());}}
​
}

面向对象实验unit2-题目1(综合性题目):面向对象实验之实现复试系统相关推荐

  1. 学堂在线python面向对象程序设计试题_面向对象程序设计-中国大学mooc-试题题目及答案...

    面向对象程序设计-中国大学mooc-试题题目及答案 更多相关问题 [单选题]下面属于"新现实主义"社会题材的影片有( ). A. <小偷家族> B. <偷自行车的 ...

  2. 程序设计语言c课程综合性实验报告,c语言综合性实验总结

    华北科技学院计算机学院综合性实验 实 验 报 告 课程名称 程序设计语言(C) 实验学期 2011 至 2012 学年 第 二 学期 学生所在学院 建筑工程学院 年级 11级 专业班级 土木B112班 ...

  3. 基于matlab毕业设计题目,matlab毕业设计题目.doc

    matlab毕业设计题目 matlab毕业设计题目 篇一:matlab毕业设计 龙岩学院 毕业设计 题目:基于matlab的音频信号处理 专业: 电子信息工程 学号: 作者: 指导教师(职称): 二0 ...

  4. matlab 毕业论文题目,matlab论文题目

    matlab论文题目 简介:本频道为与matlab论文题目和论文题目有关的范例,免费教你如何写matlab毕业设计题目提供有关文献资料. 摘要:考试与考务管理的智能化是教育走向现代化的必然趋势,它极大 ...

  5. mysql是面向对象的语言吗_php一种面向对象的语言,那么什么是面向对象呢?

    php一种面向对象的语言,那么什么是面向对象呢? 传统的面向过程的编程思想: 相信很多人第一次接触编程都是c语言,c语言就是非常典型的面向过程的编程语言,将要实现的功能描述为一个从开始到结束的连续的& ...

  6. python面向对象编程的优点-Python 基础知识----面向对象编程

    一.面向对象编程介绍 面向过程编程: 核心是过程二字,过程指的是解决问题的步骤,即先做什么再干什么然后干什么. 基于该思想编写程序好比在设计一条流水线,是一种机械式的思维方式. 优点:复杂的问题流程化 ...

  7. python面向对象和面向过程的区别_Python11-01_面向对象----面向对象和面向过程的区别...

    面向对象编程 面向对象(OPP)编程思想主要针对大型软件设计而来的.面向对象编程使程序的扩展性更加强,可读性更好.使得编程可以像搭积木一样简单. 面向对象编程将数据和操作数据的方法封装到对象中,组织代 ...

  8. 面向对象程序设计c 语言描述 答案,c面向对象程序设计习题解答全.doc

    c面向对象程序设计习题解答全 <C++面向对象程序设计>习题解答 陈腊梅 目录 TOC \o "1-3" \h \z \u HYPERLINK \l "_To ...

  9. 嵌入式Linux毕业论文题目,嵌入式毕业设计题目.doc

    嵌入式毕业设计题目 嵌入式毕业设计题目 篇一:嵌入式方向本科毕业论文题目 论文题目汇总表 2."题目类别":设计.论文: 3."题目性质":结合科研.结合生产. ...

最新文章

  1. 0x02 mysql 表格相关操作
  2. 实战KVM|kvm安装|创建linux|控制台|克隆
  3. 世界地图20亿像素_高通骁龙690 5G平台发布,支持1.92亿像素性能提升20%
  4. Docker删除镜像
  5. 在C#里调用C++的dll时需要注意的一些问题转
  6. python db2 linux 安装,python安装DB2模块
  7. 在Oracle中写出性能优良的SQL语句
  8. Java深入 - Java虚拟机性能问题监控和排查
  9. 一个让我瞠目结舌的电脑高手!(转自叁哥博客)
  10. 仿复制粘贴功能,长按弹出tips的实现
  11. ABAP中如何建数据库视图和维护视图
  12. 问题G:卡布列克常数
  13. 蚂蚱跳跃问题 【字节笔试】题目说 ”字节“跳动
  14. 删除MySQL表的SQL语句-DROP-TABLE-简介
  15. java 拉姆达 lamdba get
  16. Biopython+python 自动化分析蛋白质pdb文件,输出id,序列以及作用位点
  17. WPF圆角按钮及触发背景变更_se7en3_新浪博客
  18. Perl正则表达式讲解
  19. 开发者必须关注的工具合集,受益终生!
  20. Flex4/Flash开发在线音乐播放器 , 含演示地址

热门文章

  1. 作为一种实验的2050
  2. 中兴U880 完美版2.3.7第三弹炫目登场,你还在为刷机而烦恼?来吧!它值得你拥有!!!!...
  3. SAR ADC设计19:高速高精度比较器
  4. JPG图片怎么转成PDF还免费?
  5. RubyWin32Api Win32OLE
  6. 跳槽后,如何处理好社保公积金?
  7. Android字节跳动一面,被面试官吊打
  8. c和java哪个好找工作_C++和Java怎么选择,哪个好找工作?
  9. linux根目录空间不足,追加空间到根目录下
  10. jpg转换成PDF详细教程