欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

java實(shí)現(xiàn)背單詞程序

 更新時間:2019年07月30日 11:39:15   作者:韓韓的博客  
這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)背單詞程序,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了java實(shí)現(xiàn)背單詞程序的具體代碼,供大家參考,具體內(nèi)容如下

山東科技大學(xué)濟(jì)南校區(qū)程序設(shè)計

功能要求:可以讀入一個單詞表文本文件, 能夠?qū)⒈冲e的單詞重復(fù)記憶,直到全記住。

package java課程設(shè)計;
import java.io.*;
import java.util.*;

public class word14T {
 public static void main(String[] args) {
 // TODO Auto-generated method stub
 File file=new File("word.txt");
 //File file1=new File("wrong.txt");
 TestWord test=new TestWord();
 test.setFile(file);//類調(diào)用setfile方法
 test.setStopTime(5);//設(shè)置中間的暫停時間
 test.startTest();
 }
}
class TestWord
{
 File file; 
 int stopTime;
 public void setFile(File f)
 {
 file=f;
 }
 public void setStopTime(int t)
 {
 stopTime=t;
 }
 public void startTest()
 {
 Scanner sc=null;

 Scanner read=new Scanner(System.in);
 try
 {


  sc=new Scanner(file);
  while(sc.hasNext())
  {

  String word=sc.next();
  System.out.println(word);//顯示要背的單詞
  System.out.println("給"+stopTime+"秒背單詞的時間");
  Thread.sleep(stopTime*1000);//使程序休眠一段時間來背誦單詞
  System.out.println("\r");
  for(int i=1;i<=50;i++)
  {
   System.out.println("*");
  }//將前面的內(nèi)容覆蓋
  System.out.println("輸入曾經(jīng)顯示的單詞");
  String input=read.nextLine();//將單詞讀入input中
  if(input.equals(word))
  {
   System.out.println("單詞正確");//匹配兩個單詞是否相同
  }
  else
  {
   while(true)//將背錯的程序放在死循環(huán)中,如果正確則跳出
   { System.out.println("單詞背錯了,繼續(xù)背該單詞");
   System.out.println(word);
   FileWriter intwo=new FileWriter("wrong.txt");
   BufferedWriter tofile=new BufferedWriter(intwo);
   BufferedWriter out=new BufferedWriter(tofile);
   out.write(word);
   System.out.println("給"+stopTime+"秒背單詞的時間");
   Thread.sleep(stopTime*1000);
   System.out.println("\r");
   for(int i=1;i<=50;i++)
   {
   System.out.println("*");
   }
   System.out.println("輸入曾經(jīng)顯示的單詞");
   input=read.nextLine();
   if(input.equals(word))
   {
   System.out.println("單詞正確");
   break;
   }
  }
  }
  }
 }
 catch(Exception exp)
 {
  System.out.println(exp);
 }
 }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:

相關(guān)文章

最新評論