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

public class TableauStd implements Structure {
	
	private Object[] tableau;
	
	public TableauStd(Object[] tableau) {
		this.tableau = tableau;
	}

	@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];