Skip to content
Snippets Groups Projects
TableauStd.java 876 B
Newer Older
Thomas Lapp's avatar
Thomas Lapp committed
package p4a;

public class TableauStd implements Structure {
	
	private Object[] tableau;
	public TableauStd(int taille) {
		if (taille < 0) {
			throw new IllegalArgumentException("TableauStd : taille negative " + taille);
		}
		this.tableau = new Object[taille];

	@Override
	public void ajout(Object element, int position) {
Thomas Lapp's avatar
Thomas Lapp committed
		if (position > tableau.length) {
            throw new UnsupportedOperationException("ajout : operation non supportee (taille depassee)");
        }
        else tableau[position] = element;
	}

	@Override
	public void suppression(int position) {
		throw new UnsupportedOperationException("suppression : operation non supportee");
	}

	@Override
	public Object acces(int position) {
		if (position > tableau.length || position < 0) {
			throw new IllegalArgumentException("acces : position incorecte");
		}
		return tableau[position];