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

📄 worditem.java

📁 简单的英汉词典 用三层结构(界面层、事务处理层、数据层)编辑
💻 JAVA
字号:
/**
 * class that save the words contents node.<br>
 * Each node includes the English word, its correspoding Chinese word and a counter that represents the times they are recited.<br>
 * Date: May. 24, 2007
 *
 * @author Bai Feng
 * @version 1.8
 */
public class WordItem {
	private String english;	// English word
	private String chinese;	// Chinese word
	private int counter; // the times each word be recited
	
	/**
	 * constructor for WordItem
	 *
	 * @param english English word
	 * @param chinese Chinese word
	 */
	public WordItem(String english, String chinese ) {
		this.english = english;
		this.chinese = chinese;
		this.counter = 0;
		//System.out.println(toString());
	}
	
	/**
	 * constructor for WordItem
	 *
	 * @param english English word
	 * @param chinese Chinese word
	 * @param counter counter
	 */
	public WordItem(String english, String chinese, int counter ) {
		this.english = english;
		this.chinese = chinese;
		this.counter = counter;
		//System.out.println(toString());
	}
	
	/**
	 * judge whether two word items are equal.
	 *
	 * @param wi word item
	 * @return result(true, false)
	 */
	public boolean equals( WordItem wi ) {
		String a = wi.getEnglish()+ wi.getChinese();
		String b = getEnglish() + getChinese();
		return ( a.equals( b ) );	
	}
	
	/**
	 * convert the class to a string using the format:"english chinese"
	 *
	 * @return string converted
	 */	
	public String toString() {
		return ( getEnglish() + " " + getChinese() + " " + getCounter()  );
	}

	/**
	 * get the English word
	 *
	 * @return English word
	 */		
	public String getEnglish() {
		return english;
	}
	
	/**
	 * set the English word
	 *
	 * @param eng english word
	 */		
	public void setEnglish( String eng ) {
		this.english = eng ;
	}	

	/**
	 * get the Chinese word
	 *
	 * @return Chinese word
	 */		
	public String getChinese() {
		return chinese;
	}
	
	/**
	 * set the Chinese word
	 *
	 * @param chi Chinese word
	 */		
	public void setChinese( String chi ) {
		this.chinese = chi ;
	}
	
   /**
	 * get counter
	 *
	 * @return counter
	 */	
	public int getCounter() {
		return counter;
	}
	
   /**
	 * set counter 
	 *
	 * @param newCounter new counter value
	 */		
	public void setCounter( int newCounter ) {
		counter = newCounter;
	}
	
}	// end of class WordItem

⌨️ 快捷键说明

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