Skip to content
Snippets Groups Projects
Commit eb498ef9 authored by KLEIN ISABELLE's avatar KLEIN ISABELLE
Browse files

Upload New File

parent 00940712
Branches
No related merge requests found
package p4a;
import java.util.ArrayList;
public class SArrayList implements Structure{
/**
* @attributs
*/
private ArrayList<Double> al;
private int ordre=1000;
/**
* @constructeur
*/
public SArrayList(int ordre) {
al = new ArrayList<Double>();
this.ordre = ordre;
}
/**
* @méthodes
*/
public void ajoutEnTete(int nbElements){
for (int i = 0;i<nbElements;i++){
al.add(0,Math.random()*ordre);
}
}
public void ajoutEnQueue(int nbElements){
for (int i = 0;i<nbElements;i++){
al.add(Math.random()*ordre);
}
}
public void supprEnTete(int nbElements){
for (int i = 0;i<nbElements;i++){
al.remove(0);
}
}
public void supprEnQueue(int nbElements){
for (int i = 0;i<nbElements;i++){
al.remove(al.size()-1);
}
}
public int rechercher(Object e){
int trouve =-1;
for (int i=0; i < al.size(); i++){
if(al.get(i)==e){
trouve=i;
}
}
return trouve;
}
public void afficher(){
System.out.println("\n Structure ArrayList : ");
for (int i=0; i < al.size(); i++){
System.out.println(al.get(i)+", ");
}
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment