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

📄 taxleveltable.java

📁 计算个人所得税 GUI界面
💻 JAVA
字号:

package src;
import java.util.*;
/******************************************************
 * The tax table using a List to store members and the*
 * type of its members is TaxLevel  @see TaxValue     * 
 ******************************************************/
public class TaxLevelTable {
  private List levelTable;
  String[] tableList;
  ListIterator it;
  private int count;
  int num=0;
  public TaxLevelTable(){
	levelTable=new ArrayList();
	it=levelTable.listIterator();
	count=0;
  }
  /**
   * Get items from the List
   * @param index
   * @return TaxLevel
   * @see TaxLevel
   */
  public TaxLevel getTaxLevel(int index){
	return((TaxLevel)levelTable.get(index));
  }
  /** 
   * Sort the List according the amount  by DESC
   * @return No return value
   */
  public void sort(){ 
	if(count==0)
	  return;
	double amount1,amount2;
	TaxLevel temp=new TaxLevel();
	for(int i=0;i<count;i++)
	  for(int j=i+1;j<count-1;j++){
		amount1=((TaxLevel)levelTable.get(i)).getAmount();
		amount2=((TaxLevel)levelTable.get(j)).getAmount();
	  if(amount1<amount2){
		temp.setAttribute(amount2, ((TaxLevel)levelTable.get(i)).getRate());
		levelTable.set(i,(TaxLevel)levelTable.get(j) );
		levelTable.set(j, temp);
	  }
	}
	it=levelTable.listIterator();
	num=count;
	/***************************************************
	 * Set the levels of the items for the sorted List *
	 ***************************************************/
    while(it.hasNext())
      ((TaxLevel)it.next()).setLevel(num--);
    }
    /** 
     * Insert item to the List in Position index
     * @param tl @see TaxLevel
     * @param index int
     * @return No return value
     */
	public void insert(TaxLevel tl,int index){
    levelTable.add(index,tl);
	count++;
	sort();
  }
  /** 
   * Insert delete to the List in Position index
   * @param index int
   * @return No return value
   */
  public void delete(int index){
    levelTable.remove(index);
	count--;
	sort();
  }
  /**
   * Update items in the List in Postion index
   * @param index int
   * @param amount double
   * @param rate double 
   * @return No return value
   */
  public void update(int index,double amount,double rate){
	((TaxLevel)levelTable.get(index)).setAttribute(amount, rate);		 
  }
  /**
   * Change the items in the List to String[] stored in tableList
   * @return String[]
   */
  public String[] toStrings(){
    tableList=new String[count];
	for(int i=0;i<count;i++)
	  tableList[i]=((TaxLevel)levelTable.get(i)).toString();
	return tableList;
  }
  /**
   * get the number of items in the List
   * @return int
   */
  public int getCount(){
	return count;
   }
 }

⌨️ 快捷键说明

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