Newer
Older
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) {
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];