pooderniercours
TRANSCRIPT
![Page 1: Pooderniercours](https://reader037.vdocument.in/reader037/viewer/2022100602/55857473d8b42a472c8b4e3c/html5/thumbnails/1.jpg)
• public class Point {
• private int abs,ord;
• public int getAbs() {
• return abs;
• }
• public void setAbs(int a) {
• abs = a;
• }
• public int getOrd() {
• return ord;
• }
![Page 2: Pooderniercours](https://reader037.vdocument.in/reader037/viewer/2022100602/55857473d8b42a472c8b4e3c/html5/thumbnails/2.jpg)
• public void setOrd(int o) {
• ord = o;
• }
• Point(int a,int b)
• {abs=a;
• ord=b;}
• public String toString() {
• return " [abs=" + abs + ", ord=" + ord + "]";
• }
• }
![Page 3: Pooderniercours](https://reader037.vdocument.in/reader037/viewer/2022100602/55857473d8b42a472c8b4e3c/html5/thumbnails/3.jpg)
• public class Courbe { • private int nbrPoint , nbrMaxPoint; • private Point tab[];
• //les getteurs et les setteurs • public int getNbrPoint() { • return nbrPoint; • } • public void setNbrPoint(int n1) { • nbrPoint = n1; • } • public int getNbrMaxPoint() { • return nbrMaxPoint; • } • public void setNbrMaxPoint(int n2) { • nbrMaxPoint = n2; • } • public Point[] getTab() { • return tab; • } • public void setTab(Point[] t) { • tab = t;}
![Page 4: Pooderniercours](https://reader037.vdocument.in/reader037/viewer/2022100602/55857473d8b42a472c8b4e3c/html5/thumbnails/4.jpg)
• //le constructeur • public Courbe(int n ){ • nbrPoint=0; • nbrMaxPoint=n; • tab=new Point [n];} • //methodes possibles
• public Point minCourbe (){ • int j=0; • int minOrd=tab[0].getOrd(); • for (int i=1;i<nbrPoint;i++) • { if (tab[i].getOrd() < minOrd) j=i;} • return tab[j]; • }
• public void affiche () { • System.out.print("voici la courbe"); • for (int i=0;i<nbrPoint;i++)System.out.print(tab[i]+" ");}
![Page 5: Pooderniercours](https://reader037.vdocument.in/reader037/viewer/2022100602/55857473d8b42a472c8b4e3c/html5/thumbnails/5.jpg)
• public int chercher (Point p){ • int j=-1; • for (int i=0;i<nbrPoint;i++) • {if( (tab[i].getOrd()==p.getOrd()) &&(tab[i].getAbs()==p.getAbs())) • j=i;} • return j; }
• public void ajouter (Point p){ • if ( (nbrMaxPoint>nbrPoint) && (chercher(p)==-1) ) • { tab[nbrPoint]=p;nbrPoint ++;} • else System.out.println("tableau plein");}
• public void supprimer (Point p) { • int j = chercher(p); • if(j==-1) System.out.println("le point"+p+" n'existe meme pas dans cette
courbe !"); • else { • for (int i=j;i<nbrPoint;i++) { • tab[i]=tab[i+1];} • nbrPoint--;}} • }
![Page 6: Pooderniercours](https://reader037.vdocument.in/reader037/viewer/2022100602/55857473d8b42a472c8b4e3c/html5/thumbnails/6.jpg)
• public class TestCourbe {
• public static void main(String[] args) { • Courbe c1 = new Courbe(100); • Point p1=new Point(5,6); • Point p2=new Point(6,7); • Point p3=new Point(11,55); • Point p4=new Point(17,41); • c1.ajouter(p1); • c1.ajouter(p2); • c1.ajouter(p3); • c1.affiche();
![Page 7: Pooderniercours](https://reader037.vdocument.in/reader037/viewer/2022100602/55857473d8b42a472c8b4e3c/html5/thumbnails/7.jpg)
• Point minimum= c1.minCourbe();
• System.out.println(minimum);
• c1.supprimer(p2);
• c1.supprimer(p4);
• }
• }