如何使用java实现背单词程序
发表于:2024-10-12 作者:千家信息网编辑
千家信息网最后更新 2024年10月12日,这篇文章给大家分享的是有关如何使用java实现背单词程序的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。具体内容如下功能要求:可以读入一个单词表文本文件, 能够将背错的单词重
千家信息网最后更新 2024年10月12日如何使用java实现背单词程序
这篇文章给大家分享的是有关如何使用java实现背单词程序的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
具体内容如下
功能要求:可以读入一个单词表文本文件, 能够将背错的单词重复记忆,直到全记住。
package java课程设计;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);//类调用setfile方法 test.setStopTime(5);//设置中间的暂停时间 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("*"); }//将前面的内容覆盖 System.out.println("输入曾经显示的单词"); String input=read.nextLine();//将单词读入input中 if(input.equals(word)) { System.out.println("单词正确");//匹配两个单词是否相同 } else { while(true)//将背错的程序放在死循环中,如果正确则跳出 { System.out.println("单词背错了,继续背该单词"); 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("输入曾经显示的单词"); input=read.nextLine(); if(input.equals(word)) { System.out.println("单词正确"); break; } } } } } catch(Exception exp) { System.out.println(exp); } }}
感谢各位的阅读!关于"如何使用java实现背单词程序"这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
单词
程序
内容
时间
更多
篇文章
输入
不错
实用
相同
两个
功能
文件
文本
文章
方法
看吧
知识
记忆
课程
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
从服务器检索信息
access数据库干什么的
华为软件开发员待遇
计算机网络技术就业方向哪个
数据库改怎么用
被知名数据库收录情况
公安部网络安全监控
QQ定位数据库最新版
通信网络技术领域
上海博泰悦臻网络技术招聘
腾讯云安卓系统服务器
统一用户认证服务器
中职计算机网络技术操作题
软件开发前提出的问题
天河云cad数据库调不出来
幻塔悯雨岛服务器在哪里
济有科技管理软件开发商
西安乌托派网络技术有限公司网址
软件开发调试差旅
数据库实验报告4
mysql数据库基础笔记
黄网 国外服务器
电商erp软件开发报价
怎么样建立个人数据库
安卓数据库怎么连接
软件开发项目管理笔试
软件开发产品开发体系
数据库的findall
三河市网络技术
长春壹和网络技术有限公司