当前位置: 首页 > news >正文

专业做网站制作的公司百度退款客服电话

专业做网站制作的公司,百度退款客服电话,做外贸必须有网站吗,村级民主法治建设网站文章目录 一&#xff0c;项目要求二&#xff0c;创建实体类ExamItem三&#xff0c;创建考试服务类ExamService3.1 全局变量 考题列表itemList(List< ExamItem >类型)&#xff0c;答案数组answerArr (String[]类型)&#xff0c;得分score3.2 初始化方法init()3.3 打印菜单…

文章目录

  • 一,项目要求
  • 二,创建实体类ExamItem
  • 三,创建考试服务类ExamService
    • 3.1 全局变量 考题列表itemList(List< ExamItem >类型),答案数组answerArr (String[]类型),得分score
    • 3.2 初始化方法init()
    • 3.3 打印菜单的方法printMenu()
    • 3.4 开始考试方法startExam()
    • 3.5 判卷方法judgeExam()
    • 3.6 打印上次成绩方法printLastExam()
  • 四,创建考试测试类
  • 五,测试
  • 六,考题

一,项目要求

考试系统要实现:菜单功能打印,考试,查看上次考试成绩,退出系统等功能。
(1) 通过Idea创建工程,在exam包里创建一个考题类ExamItem,包含考试题目title,选项一optionA,
选项二optionB,选项三optionC,选项四optionD,正确答案answer属性。
(2) 在exam包里创建一个考试服务类ExamService,包含一个考题列表itemList(List< ExamItem >类
型),答案数组answerArr (String[]类型),得分score。包含一个初始化方法public void init(),开始考试
方法public void startExam(),判卷的方法private void judgeExam(),保存用户答案和成绩的方法
public void save(),打印上次考试成绩的方法public void printLastExam(),打印菜单的方法public
void printMenu()

init方法的作用是从 Items.txt 文件中读取数据,把数据封装成ExamItem对象,把对象存入
itemList中,并根据itemList的size大小,初始化answerArr数组,在ExamService的无参构造方法
里调用init方法进行初始化。
startExam的作用是开始考试,打印考题,处理用户操作。
judgeExam的作用是根据用户的答案,和正确答案进行判卷,
save的作用是保存用户答案和成绩,把自己每道题的答案,考试得分存入 result.txt 文件中。
printLastExam的作用是打印上次考试的成绩,即save中存储的内容。

(3) 在exam包里创建一个考试系统类ExamSystem,在main方法中写程序的流程,完成每个菜单的功能

二,创建实体类ExamItem

包含
考试题目title,选项一optionA,选项二optionB,选项三optionC,选项四optionD,正确答案answer属性

public class ExamItem {private String title;private String optionA;private String optionB;private String optionC;private String optionD;private String answer;@Overridepublic String toString() {return title+"\n"+optionA+"\n"+optionB+"\n"+optionC+"\n"+optionD+"\n";}public ExamItem(String title, String optionA, String optionB, String optionC, String optionD, String answer) {this.title = title;this.optionA = optionA;this.optionB = optionB;this.optionC = optionC;this.optionD = optionD;this.answer = answer;}public ExamItem() {}public String getTitle() {return title;}public void setTitle(String title) {this.title = title;}public String getOptionA() {return optionA;}public void setOptionA(String optionA) {this.optionA = optionA;}public String getOptionB() {return optionB;}public void setOptionB(String optionB) {this.optionB = optionB;}public String getOptionC() {return optionC;}public void setOptionC(String optionC) {this.optionC = optionC;}public String getOptionD() {return optionD;}public void setOptionD(String optionD) {this.optionD = optionD;}public String getAnswer() {return answer;}public void setAnswer(String answer) {this.answer = answer;}
}

三,创建考试服务类ExamService

3.1 全局变量 考题列表itemList(List< ExamItem >类型),答案数组answerArr (String[]类型),得分score

	//  考题List<ExamItem> itemList = new ArrayList<ExamItem>();//  答案数组String answerArr[];//  得分double score=0;

3.2 初始化方法init()

将初始化方法init放入考试服务类的无参构造器中,在创建对象时就调用达到初始化的目的
使用字符缓冲输入流读取已经保存好的考题文本
1.创建泛型为String的list列表
2.使用BufferedReader 中的readline方法读取每一行数据
3.将不是为“空行”的值添加到list中
4.遍历list,将数据存放入list中
5.根据题目的数量初始化答案数组answerArr的长度,并将正确答案放入数组中

public ExamService() {init();}public void init(){List<String> list = new ArrayList<>();//  使用try-with-resource  自动释放资源try (BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\86155\\Desktop\\作业\\27考试系统\\Items.txt"));){//  定义字符串接收每一行String line ;while ((line = br.readLine()) != null) {if(!line.equals("")){       //如果不是空行则放入listlist.add(line);}}for (int i = 0; i < list.size(); i+=6) {//  将for循环中得到的数据添加到list中ExamItem examItem = new ExamItem(list.get(i), list.get(i+1), list.get(i+2), list.get(i+3), list.get(i+4), list.get(i+5));itemList.add(examItem);}//  根据题目的数量初始化答案数组的长度answerArr=new String[itemList.size()];//  将题号对应答案放入数组for(int i=0;i<itemList.size();i++){answerArr[i]=itemList.get(i).getAnswer();}} catch (IOException e) {throw new RuntimeException(e);}}

3.3 打印菜单的方法printMenu()

开始考试后用来提示操作的菜单

//  打印菜单public void printMenu(){System.out.println("----------欢迎进入考试-----------" +"\n    使用以下按键进行考试:" +"\n    A-D:选择指定答案" +"\n    P   :显示上一题" +"\n    N   :显示下一题" +"\n    F   :交卷" +"\n\n      请按N键进入考试...");while(true){String s =sc.next();if (s.equalsIgnoreCase("N")) {break;} else {System.out.println("输错了,请按N键");}}}

3.4 开始考试方法startExam()

考试步骤:
1.提示菜单,进行操作
2.创建临时答案字符串数组ans[]和接收控制台输入值的a
3.for循环遍历考题列表itemList并打印
4.判断当前题目是否已经填写答案
5.输入操作----输入A-D填写答案,P上一题,N下一题,F交卷
6.判断操作(下一题----continue;上一题----i减2;最后一题已经填写----i减1;输错了----i减1)
7.交卷操作(提示还有没有没做的题目)确认交卷后调用判卷方法judgeExam()进行判卷

//  开始考试public void startExam(){//  打印菜单,选择开始printMenu();//  将临时答案用字符串数组保存String a ;  //  接收输入的值String ans[] = new String[itemList.size()];for(int i=0;i<itemList.size();i++){//  打印试卷System.out.println(itemList.get(i).toString());//  判断当前是否已经有答案if(ans[i]!=null&&!ans[i].equalsIgnoreCase("N")&&!ans[i].equalsIgnoreCase("P")){System.out.println("您这道题已经作答,选的是"+ans[i]+",输入A-D更换答案,P上一题,N下一题,F交卷:");}a =sc.next();//  上一题if(a.equalsIgnoreCase("P")){if(i==0){System.out.println("已经是第一题了!");} else{i -= 2;continue;}}//  下一题else if (a.equalsIgnoreCase("N")) {if(i==itemList.size()-1){System.out.println("已经是最后一题了!");}else {System.out.println("已跳过该题");continue;}}//  交卷else if(a.equalsIgnoreCase("F")){for(int j=0;j<itemList.size();j++){if(ans[j]==null){System.out.println("第"+(j+1)+"题还没有做");}}System.out.println("确定提交试卷吗?(Y/N)");String choice = sc.next();if(choice.equalsIgnoreCase("Y")){//  考完试调用判卷方法进行判卷judgeExam(ans);break;}else if(a.equalsIgnoreCase("N")){}}//  判断输入的答案是否合法while(true){//  输入abcd格式正确则放入数组if (a.equalsIgnoreCase("A") || a.equalsIgnoreCase("B") || a.equalsIgnoreCase("C") || a.equalsIgnoreCase("D")) {ans[i]=a;break;}else{//  输错了则把值设置为nullif(ans[i]!=null&&!(ans[i].equalsIgnoreCase("A") || ans[i].equalsIgnoreCase("B") || ans[i].equalsIgnoreCase("C") || ans[i].equalsIgnoreCase("D"))){ans[i] = null;}System.out.println("请选择正确答案");i--;break;}}//  最后一题写完后if(i==itemList.size()-1){i--;}}}

3.5 判卷方法judgeExam()

判卷过程:
1.遍历正确答案数组与选择的答案进行比对
2.计分
3.使用字符缓冲输出流BufferedWriter将考试结果写入文本文件
4.分数重新赋值为0

//  判卷private void judgeExam(String ans[]){try (BufferedWriter bw=new BufferedWriter(new FileWriter("C:\\Users\\86155\\Desktop\\作业\\27考试系统\\result.txt"));){//  遍历  计分并将答案写入记事本for(int i=0;i<answerArr.length;i++){if(ans[i]!=null){bw.write(ans[i] + "-----------正确答案:" + answerArr[i] + "\n");if (ans[i].equalsIgnoreCase(answerArr[i])) {score += 100/itemList.size()/1.0;}}else bw.write( "未选择答案-----------正确答案:" + answerArr[i] + "\n");}bw.write("得分:"+score+"\n");score=0;} catch (Exception e) {throw new RuntimeException(e);}}

3.6 打印上次成绩方法printLastExam()

使用字符缓冲输入流BufferedReader读取保存考试结果的文本文件并输出显示

//  打印上次考试成绩public void printLastExam(){try(BufferedReader bufferedReader = new BufferedReader(new FileReader("C:\\Users\\86155\\Desktop\\作业\\27考试系统\\result.txt"))){char ch[]= new char[1024];int len;while((len=bufferedReader.read(ch))!=-1){System.out.print(new String(ch,0,len));}} catch (Exception e) {throw new RuntimeException(e);}}

四,创建考试测试类

public class Test {public static void main(String[] args) {ExamService examService = new ExamService();Scanner sc = new Scanner(System.in);while(true){System.out.println("=====================" +"\n     小孤鸡考试系统" +"\n     1.进入考试" +"\n     2.查看上次考试成绩" +"\n     3.退出系统" +"\n     请选择:");int num = 0;try {num = sc.nextInt();} catch (Exception e) {throw new RuntimeException("输入格式错了,只能为数字");}switch (num) {case 1:examService.startExam();break;case 2:examService.printLastExam();break;case 3:System.out.println("已退出!");return;default:System.out.println("输错了!");break;}}}
}

五,测试

1.开始考试
在这里插入图片描述
2.下一题
在这里插入图片描述
3.上一题
在这里插入图片描述
4.最后一题写完
在这里插入图片描述
5.交卷
在这里插入图片描述
6.查看上一次考试结果
在这里插入图片描述
7.退出系统
在这里插入图片描述

六,考题

第1题 Java语言是哪年发明的?
A. 1991
B. 1994
C. 1996
D. 1999
C

第2题 下列关于JDK、JRE和JVM的描述,哪项正确?
A. JDK中包含了JRE,JVM中包含了JRE
B. JDK中包含了JRE,JRE中包含了JVM
C. JRE中包含了JDK,JVM中包含了JRE
D. JRE中包含了JDK,JDK中包含了JVM
B

第3题 用于生成Java文档的JDK工具是?
A. javac
B. jdb
C. javadoc
D. junit
C

第4题 使用JDK工具生成的Java文档的文件格式是?
A. XML格式
B. HTML格式
C. 二进制格式
D. 自定义格式
B

第5题 以下关于支持Java运行平台的叙述,哪项错误?
A. Java可在Solaris平台上运行
B. Java可在Windows平台上运行
C. Java语言与平台无关。Java程序的运行结果与操作系统无关
D. Java语言与平台无关。Java程序的运行结果依赖于操作系统
D

第6题 JVM在执行一个Java类时,大致采用以下过程?
A. 装载类->校验类->执行类中的代码
B. 校验类->装载类->执行类中的代码
C. 装载类->执行类中的代码->校验类
D. 执行类中的代码->装载类->校验类
A

第7题 用于编译Java源文件的JDK工具是?
A. javac
B. jdb
C. java
D. junit
A

第8题 Java程序的跨平台特征是由以下哪项技术实现的?
A. 系统硬件
B. JVM
C. Java编译器
D. 操作系统
B

第9题 下列有关类、对象和实例的叙述,正确的是哪一项?
A. 类就是对象,对象就是类,实例是对象的另一个名称,三者没有差别
B. 类是对象的抽象,对象是类的具体化,实例是对象的另一个名称
C. 对象是类的抽象,类是对象的具体化,实例是对象的另一个名称
D. 类是对象的抽象,对象是类的具体化,实例是类的另一个名称
B

第10题 Java源文件的后缀名是?
A. .class
B. .c
C. .java
D. .txt
C


文章转载自:
http://dinncotartly.zfyr.cn
http://dinncoconsuetude.zfyr.cn
http://dinncoproliferous.zfyr.cn
http://dinncobelladonna.zfyr.cn
http://dinncopanax.zfyr.cn
http://dinncounredeemable.zfyr.cn
http://dinncosubastral.zfyr.cn
http://dinncodaydream.zfyr.cn
http://dinncoalarm.zfyr.cn
http://dinncoreaper.zfyr.cn
http://dinncobronchotomy.zfyr.cn
http://dinncovassalage.zfyr.cn
http://dinncoviole.zfyr.cn
http://dinncochittamwood.zfyr.cn
http://dinncolineskipper.zfyr.cn
http://dinncolimitary.zfyr.cn
http://dinncoexchangeability.zfyr.cn
http://dinncononpayment.zfyr.cn
http://dinncowarhead.zfyr.cn
http://dinncojudaica.zfyr.cn
http://dinncoprosopyle.zfyr.cn
http://dinncouraemia.zfyr.cn
http://dinncosabbathbreaker.zfyr.cn
http://dinncouncharity.zfyr.cn
http://dinncolimay.zfyr.cn
http://dinncoparatransit.zfyr.cn
http://dinncoobnoxious.zfyr.cn
http://dinncorhymeless.zfyr.cn
http://dinncocoalball.zfyr.cn
http://dinncomicrophotometer.zfyr.cn
http://dinncooxygenic.zfyr.cn
http://dinncocorrasion.zfyr.cn
http://dinncoraphis.zfyr.cn
http://dinncoagrologic.zfyr.cn
http://dinncoeatery.zfyr.cn
http://dinncoloadstar.zfyr.cn
http://dinncoaluminothermy.zfyr.cn
http://dinncocockleshell.zfyr.cn
http://dinncoelse.zfyr.cn
http://dinncoingress.zfyr.cn
http://dinncoconciliationism.zfyr.cn
http://dinncocripplehood.zfyr.cn
http://dinncogastrostomy.zfyr.cn
http://dinncocompanionship.zfyr.cn
http://dinncoarchil.zfyr.cn
http://dinncofishery.zfyr.cn
http://dinnconiggerize.zfyr.cn
http://dinncoprismoid.zfyr.cn
http://dinncocaspian.zfyr.cn
http://dinncoclue.zfyr.cn
http://dinncocashdrawer.zfyr.cn
http://dinncofursemide.zfyr.cn
http://dinncoxanthone.zfyr.cn
http://dinncomalathion.zfyr.cn
http://dinncostylite.zfyr.cn
http://dinncogherkin.zfyr.cn
http://dinncolocomotion.zfyr.cn
http://dinncohoarsely.zfyr.cn
http://dinncoclemency.zfyr.cn
http://dinncoelectrocardiogram.zfyr.cn
http://dinncoweirdness.zfyr.cn
http://dinncoyawping.zfyr.cn
http://dinncohant.zfyr.cn
http://dinncoedgy.zfyr.cn
http://dinncoprognathism.zfyr.cn
http://dinncopatienthood.zfyr.cn
http://dinncothyrsi.zfyr.cn
http://dinncopinchfist.zfyr.cn
http://dinncocompotier.zfyr.cn
http://dinncoafterbody.zfyr.cn
http://dinncohumid.zfyr.cn
http://dinncoimpaste.zfyr.cn
http://dinnconeorican.zfyr.cn
http://dinncokermes.zfyr.cn
http://dinncojolt.zfyr.cn
http://dinncoclubman.zfyr.cn
http://dinncoanal.zfyr.cn
http://dinncopam.zfyr.cn
http://dinncothivel.zfyr.cn
http://dinncohemicycle.zfyr.cn
http://dinncolamplight.zfyr.cn
http://dinncolimehouse.zfyr.cn
http://dinncofetterbush.zfyr.cn
http://dinncocut.zfyr.cn
http://dinncobarrowman.zfyr.cn
http://dinncotzaddik.zfyr.cn
http://dinncocobia.zfyr.cn
http://dinncogallabiya.zfyr.cn
http://dinncoesotropia.zfyr.cn
http://dinncoraintight.zfyr.cn
http://dinncoammunition.zfyr.cn
http://dinncopiezoresistance.zfyr.cn
http://dinncopilular.zfyr.cn
http://dinncoundistributed.zfyr.cn
http://dinncocounting.zfyr.cn
http://dinncohiatus.zfyr.cn
http://dinncoadoptable.zfyr.cn
http://dinncobesprent.zfyr.cn
http://dinncoinnutritious.zfyr.cn
http://dinncorisque.zfyr.cn
http://www.dinnco.com/news/97404.html

相关文章:

  • 个人网站制作手机版灰色词优化培训
  • 两学一做网站进不去seo排名点击器
  • 东莞虎门二手房价最新消息宁波正规seo推广
  • 传媒网站制作项目营销推广策划
  • 丽水网站建设搜索排名怎么做
  • 今天出京入京最新通知免费检测网站seo
  • 网站上投放广告西安网站seo工作室
  • 百度做的网站字体侵权吗百度指数官方下载
  • 怎样做网站模板百度信息流优化
  • wordpress 添加设置营销网站seo推广
  • 可以访问电脑网页的浏览器保定百度seo排名
  • 南京高端网站设计天津百度seo推广
  • 建设执业资格注册管理中心网站如何做谷歌seo推广
  • 宁波网站推广优化公司怎么样网络营销推广处点
  • 自贡建设专业网站设计百度上如何做优化网站
  • 在线原型设计网站seo优化便宜
  • 网站专题页做多大尺寸快速优化seo软件推广方法
  • 做云词图的网站长沙seo推广公司
  • 企业网站建设河北潍坊网站建设seo
  • 莱芜企业建站公司精准营销系统价值
  • 我要找人做网站的主页网页制作软件推荐
  • 国外有哪些网站可以做电商应用商店关键词优化
  • 上海注册公司核名在哪个网站郴州网站定制
  • 做网站建设公司crm在线的培训服务seo建站公司推荐
  • wordpress视频列表重庆镇海seo整站优化价格
  • 党建网站建设考核评比百度收录关键词
  • 网站建设美国下载百度2023最新版安装
  • app网站建设需要什么知了seo
  • 黄冈网站推广下载有名的seo外包公司
  • 鲤城区建设局网站推广文章