广州微信网站建设公司,沈阳正规网站建设哪家便宜,企业建设网站目的是什么意思,厦门网站建设制作多少钱本文实例为大家分享了java实现背单词程序的具体代码#xff0c;供大家参考#xff0c;具体内容如下山东科技大学济南校区程序设计功能要求#xff1a;可以读入一个单词表文本文件#xff0c; 能够将背错的单词重复记忆#xff0c;直到全记住。package java课程设计;import…本文实例为大家分享了java实现背单词程序的具体代码供大家参考具体内容如下山东科技大学济南校区程序设计功能要求可以读入一个单词表文本文件 能够将背错的单词重复记忆直到全记住。package java课程设计;import java.io.*;import java.util.*;public class word14T {public static void main(String[] args) {// TODO Auto-generated method stubFile filenew File(word.txt);//File file1new File(wrong.txt);TestWord testnew TestWord();test.setFile(file);//类调用setfile方法test.setStopTime(5);//设置中间的暂停时间test.startTest();}}class TestWord{File file;int stopTime;public void setFile(File f){filef;}public void setStopTime(int t){stopTimet;}public void startTest(){Scanner scnull;Scanner readnew Scanner(System.in);try{scnew Scanner(file);while(sc.hasNext()){String wordsc.next();System.out.println(word);//显示要背的单词System.out.println(给stopTime秒背单词的时间);Thread.sleep(stopTime*1000);//使程序休眠一段时间来背诵单词System.out.println(\r);for(int i1;i50;i){System.out.println(*);}//将前面的内容覆盖System.out.println(输入曾经显示的单词);String inputread.nextLine();//将单词读入input中if(input.equals(word)){System.out.println(单词正确);//匹配两个单词是否相同}else{while(true)//将背错的程序放在死循环中如果正确则跳出{ System.out.println(单词背错了继续背该单词);System.out.println(word);FileWriter intwonew FileWriter(wrong.txt);BufferedWriter tofilenew BufferedWriter(intwo);BufferedWriter outnew BufferedWriter(tofile);out.write(word);System.out.println(给stopTime秒背单词的时间);Thread.sleep(stopTime*1000);System.out.println(\r);for(int i1;i50;i){System.out.println(*);}System.out.println(输入曾经显示的单词);inputread.nextLine();if(input.equals(word)){System.out.println(单词正确);break;}}}}}catch(Exception exp){System.out.println(exp);}}}以上就是本文的全部内容希望对大家的学习有所帮助也希望大家多多支持我们。时间 2019-07-28