📄 simpledictionary.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 + -