⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simpledictionary.java

📁 使用面向对象方法完成“快速拼写检查程序”的分析、设计和实现过程。快速拼写检查程序基本要求说明如下: 1.进行拼写检查的文件以文本文件形式存储于外存上;2.只检查文件中英文单词的拼写错误;3.单词是用字
💻 JAVA
字号:
package tokenchecker;

import java.io.Serializable;
import java.util.TreeSet;
import java.io.*;
/**
 * class SimpleDictionary is a simple dictionary used to check
 * the word is correct or not 
 */
 
public class SimpleDictionary implements Serializable { 
	
	private String name;
	private String info;
	private boolean changed;
	private TreeSet treeset;
	
	public SimpleDictionary() {
		name = new String();
		info = new String();
		treeset = new TreeSet();		
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		if(!this.name.equals(name)){
			this.name = name;
			changed = true;
		}
	}
	public String getInfo() {
		return info;
	}
	public void setInfo(String info) {
		if(!this.info.equals(info)){
			this.info = info;
			changed = true;
		}
	}
	public boolean isChanged() {
		return changed;
	}
	public void saveChanged() throws IOException {
		ObjectOutputStream objOut = new ObjectOutputStream(
							new FileOutputStream(this.getName()));
				objOut.writeObject(this);
	}
	public boolean containsWord(String word) {
		return treeset.contains(word);
	}
	public void addWord(String word) {
		System.out.println("here in add word .the word is " + word);
		treeset.add(word);
		changed = true;
	}
	public boolean removeWord(String word) {
		System.out.println("here in remove word .the word is " + word);
		changed = true;
		return treeset.remove(word);
	}	  
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -