1.媒介:
第一次作业难度较大,从无到有的设计,涉及到的主要类有Paper,Question,AnswerPaper,Main,主要题目方向为字符串判断与字符串处置惩罚(提取有用信息),判断对错算总分,配合一些Java自带的数据布局如ArrayList即可快速解决问题,第一次作业是后面作业的基础,需自行了解正则表达式等方法。第二次作业难度适中,题目在第一次作业前提下添加了试卷类,涉及较为复杂类引用,必要对类的引用有一定了解。第三次作业难度最高,在前两次作业基础上添加学生信息及删除题号,还添加了许多错误提示及错误提示优先级显示。这三次作业的难度可以说是逐次递增,必要学生在第一次作业建立精良的类布局,并在第二次作业中添加类,以及第三次作业给删除的题目添加标志以执行语句都是难点。这三次PTA作业观察了学生构建步伐框架的能力,以及正则表达式提取所需信息,ArrayList储存内容等方面的知识。
2.设计与分析:
第一次作业:
只需用AnswerPaper判断,Paper储存Question数组。由于当时还未学习ArrayList,使用数组储存,设计上采用两个字符串数组,一个数组装题目(题号与题目对应),一个数组装写的答案(题号与标准的答案对应),传递到AnswerPaper中举行比较。Question类封装题目信息,包括题号、题目内容、标准答案、作答;末了再将Question类封装进AnswerPaper类,其方法为判断答案与标准答案是否雷同,末了举行输出。
建立Question类储存数据
点击检察源码- class Question{
- private int num;
- private String content;
- private String standard_answer;
- private String answer;
- private boolean result;
- public Question(){}
- public Question(int num,String content,String standard_answer,String answer,boolean result){
- this.num=num;
- this.content=content;
- this.standard_answer=standard_answer;
- this.answer=answer;
- this.result=result;
- }
- public String getStandard_Answer(){
- return standard_answer;
- }
- public void setStandard_Answer(String standard_answer){
- this.standard_answer=standard_answer;
- }
- public String getContent(){
- return content;
- }
- public void setContent(String content){
- this.content=content;
- }
- public int getNum(){
- return num;
- }
- public void setNum(int num){
- this.num=num;
- }
- public void setAnswer(String answer){
- this.answer=answer;
- }
- public String getAnswer(){
- return answer;
- }
- public void setResult(boolean result){
- this.result=result;
- }
- public boolean getResult(){
- return this.result;
- }
- public boolean TF(){
- if(standard_answer==answer)
- {
- result=true;
- }
- else
- {
- result=false;
- }
- return result;
- }
- }
复制代码 建立AnswerPaper类以便判断点击检察源码[code]class AnswerPaper{ private Paper paper; private Question []question=new Question[1000]; public AnswerPaper(Paper paper,String str,int num){ this.paper=paper; String answer1; boolean result; String strs[]=str.split(" #"); for(int i=0;i |