pkwarray.java

来自「二手车管理软件」· Java 代码 · 共 98 行

JAVA
98
字号
/** Programmname : PkwArray <br>
Klasse : <b> PkwArray </b>
@autor Li,Haibin   Hou,Yujing   Zhang,Xiangpeng
@version 1.0 / 15.12.2006
*/

import java.util.Observable;
import java.util.ArrayList;

public class PkwArray extends Observable {
	/** Liste der Pkw's */
	private ArrayList PkwList;

	private int count;

	/**
	 * private Methode, die den Observer benachrichtigt und die Inhalte
	 * Aktualisiert
	 */
	public void changes() {
		setChanged();
		notifyObservers();
	}

	/** Konstruktor */
	public PkwArray() {
		PkwList = new ArrayList();
		count = 0;
	}
	
	/** Konstruktor
	 * 
	 * @param int
	 */
	public PkwArray(int capacity) {
		PkwList = new ArrayList(capacity);
		count = 0;
	}

	/**
	 * fuegt einen Pkw zur Liste hinzu
	 * 
	 * @param Pkw
	 */
	public boolean insert(Pkw p) {
		boolean b = PkwList.add(p);
		count++;
		changes();
		return b;
	}

	/**
	 * loescht einen Pkw aus der Liste
	 * 
	 * @param Pkw
	 */
	public boolean remove(Pkw p) {
		boolean b = PkwList.remove(p);
		count--;
		changes();
		return b;
	}
	
	/**
	 * loescht einen Pkw aus der Liste
	 * 
	 * @param int
	 */
	public Pkw remove(int index) {
		Pkw p = (Pkw)PkwList.remove(index);
		count--;
		changes();
		return p;
	}
	
	/**
	 * gibt einen Pkw aus der Liste zurueck
	 * 
	 * @param int
	 */
	public Pkw getPkw(int index) {
		return (Pkw)PkwList.get(index);
	}
	/**
	 * gibt Anzahl Pkw in der PkwList zurueck
	 */
	public int getCount() {
		return count;
	}
	
	/**
	 * gibt die PkwList zurueck
	 */
	public ArrayList getPkwList() {
		return PkwList;
	}
}

⌨️ 快捷键说明

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