日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

用java程序实现记单词_java实现背单词程序

發(fā)布時間:2023/12/4 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 用java程序实现记单词_java实现背单词程序 小編覺得挺不錯的,現(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í)有所幫助,也希望大家多多支持我們。

時間: 2019-07-28

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結(jié)

以上是生活随笔為你收集整理的用java程序实现记单词_java实现背单词程序的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。