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

📄 worddb.java

📁 简单的英汉词典 用三层结构(界面层、事务处理层、数据层)编辑
💻 JAVA
字号:
import java.util.*;	// using class LinkedList

 /**
  * Data hierarchy: realize the word database basic function inherited from class LinkedList. The word element is stored in class WordItem.<br> 
  * This class stores the word database, can add a new word to the front of the words existed.<br>
  * It can also load words from a file to the database.<br>
  *
  *	Date: May. 28, 2007
  *
  * @author Bai Feng
  * @version 1.8
  */
 public class WordDB extends LinkedList {

	/**
	 * constructor for WordDB
	 *
	 */	 	
 	public WordDB() {
 		super();	// call parent class constructor	
 	}
 	 		
	/**
	 * judge if the word database is empty
	 *
	 * @return result(true, flase) 	 		
	 */
 	public boolean isEmpty() {
 		return ( size() == 0 );
 	}
 	
 	/**
 	 * add a new word to the front of the dictionary
 	 *
 	 * @param wi a word item
 	 */ 	
 	public boolean add( Object wi ) {
		addFirst( ( WordItem ) wi );
		//System.out.println( toString() );
		return true;
 	}	// end of method add()
 	
   /**
 	 * add a new word to the last position of the dictionary according to the sequence in the file.
 	 *
 	 * @param wi a word item
 	 */
 	public boolean loadWordDB( Object wi ) {
 		addLast( ( WordItem ) wi );
 		return true;
 	}
 	
	/**
	 * convert the class to a string.
	 *
	 * @return string converted
	 */	 	
 	public String toString() {
 		String result = "";
 		ListIterator iter = listIterator( 0 );

		if ( iter.hasNext() ) {
			result = (( WordItem ) iter.next() ).toString() + "\n";
		}

		while ( iter.hasNext() ) {
			result += (( WordItem ) iter.next()).toString() + "\n";
		} 		
 		return result;
 	}	// end of method toString()

}	// end of class WordDB

⌨️ 快捷键说明

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