资源简介
用来记录生词,可随机抽取单词进行巩固知识的小程序

代码片段和文件信息
package com.dingge.words.input;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.swing.Jframe;
import javax.swing.JOptionPane;
public class ClientContext {
private Mainframe mainframe;
public void setMainframe(Mainframe mainframe){
this.mainframe = mainframe;
}
private Reserveframe reserveframe;
public void setReserveframe(Reserveframe reserveframe){
this.reserveframe = reserveframe;
}
private Startframe startframe;
public void setStartframe(Startframe startframe){
this.startframe = startframe;
}
public void show(){
startframe.setVisible(true);
}
public void start(){
mainframe.setVisible(true);
startframe.setVisible(false);
}
public void reserve(){
reserveframe.updateview();
reserveframe.setVisible(true);
}
public void cancel(){
reserveframe.setVisible(false);
}
public void exit(Jframe source){
int val =JOptionPane.showConfirmDialog(source “真的不背单词了?“);
if(val==JOptionPane.YES_OPTION){
System.exit(0);
}
}
private HashMap words =
new HashMap();
private int ind;
public void loadWords(String filename) throws IOException {
try {
BufferedReader in = new BufferedReader(new FileReader(filename));
String line;
while((line = in.readLine()) != null){
line = line.trim();
if(line.equals(““)){
continue;
}
Word one = parseWord(line);
words.put(one.getIndex() one);
}
ind = words.size();
in.close();
}catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//private Word wordall = new Word();
public Word parseWord(String line){
String[] data = line.split(“:“);
Word wordall = new Word();
wordall.setIndex(Integer.parseInt(data[0]));
wordall.setWord(data[1]);
wordall.setChinese(data[2]);
wordall.setProperty(data[3]);
return wordall;
}
private List list = new ArrayList(words.values());;
public Word createWord() throws IOException{
loadWords(“word.txt“);
list = new ArrayList(words.values());
int pos = (int)Math.floor(Math.random()*list.size());
Word oneWord = list.get(pos);
return oneWord;
}
private Word randomWord;
private boolean showWordis = false;
public void showWord(){
try {
randomWord = createWord();
mainframe.updateView(randomWord);
showWordis = true;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void showWordAll(){
if(showWordis){
mainframe.updateViewAll(randomWord);
showWordis = false;
}else{
JOptionPane.showMessageDialog(null “亲,请先随机抽取新单词“);
}
}
private String w
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2340 2013-10-11 23:45 input\cd.png
文件 4128 2013-10-18 16:06 input\ClientContext.java
文件 679 2013-10-14 11:44 input\Main.java
文件 2682 2013-10-18 12:29 input\Mainfr
文件 177 2013-10-10 16:31 input\Reserve.java
文件 3301 2013-10-18 16:06 input\Reservefr
文件 1610 2013-10-15 11:38 input\Startfr
文件 834 2013-10-16 12:42 input\Word.java
目录 0 2013-10-21 12:46 input
----------- --------- ---------- ----- ----
15751 9
- 上一篇:labview编写比较高级计算器
- 下一篇:OpenNI.dll
相关资源
- CoreUIVue是基于Bootstrap4的免费Vue管理模
- SpringBoot+H2+mybatis-plus59130
- 登录注册界面.zip48872
- 数字华容道
- SSM+Shiro+redis实现单点登陆
- jstl-api-1.2和jstl-impl-1.2
- 基于MVC模式的会员管理系统
- 国内一家大型软件公司内部的正规软
- 仿windows记事本
- GUI银行管理系统
- 超市收银系统eclipse access大学课程设计
- 模拟ATM柜员机系统--连接数据库
- A*算法的2D演示(带源码)
- 代码审查表和代码审查实例
- 仿126 网易 163 邮箱 界面
- Tomcat6.x
- 简单的行编辑器
- 扫雷(MVC架构)
- 302 Found
- window ping命令加时间并记录日志
- springboot+rabbitmq项目demo(亲测可正常运
- jxbrowser 所有版本通用的破解包
- 2017年-传智播客-张志君老师-SpringBoo
- Blob.js+Export2Excel.js
- 机会路由源代码+仿真工具(SCORP)
- POI中文帮助文档附带api手册.zip
- 2018双十一阿里供应链服务平台讲座
- 原银在线信贷平台概要设计说明书v
- office_word_api 开发文档
- sun.misc.Unsafe源码
评论
共有 条评论