X-Git-Url: https://git.piment-noir.org/?p=TP_POO.git;a=blobdiff_plain;f=TP2%2FMain.java;h=85c21fe2384a48564712366c5083c17db504b4ca;hp=64a54e79985048dbd29e4c503318efe10e2aa089;hb=22758baf926b8b833ce6a38566eb157e13fbd3fb;hpb=b026092f10431b439dfa497725801e4336aa0348 diff --git a/TP2/Main.java b/TP2/Main.java index 64a54e7..85c21fe 100644 --- a/TP2/Main.java +++ b/TP2/Main.java @@ -11,6 +11,9 @@ class Main { Piletransformations trans = new Piletransformations(10); boolean rt = trans.empiler(p4); + if (!rt) { + System.out.println("Echec empilation"); + } segment.dessiner(trans); cercle.dessiner(trans); @@ -55,14 +58,95 @@ class Main { image2.dessiner(transformations); Point point2 = new Point(0.5, 2.5); image1.deplacer(point2); - image2.ajouter(image1); - image2.dessiner(transformations); + image3.ajouter(image1); + image3.ajouter(image2); + image3.dessiner(transformations); transformations.depiler(); } + public static void main3() { + + Affichable[] affichable = new Affichable[10]; + + Point p1 = new Point(1, 2); + Point p2 = new Point(2, 7); + Point p3 = new Point(1, 5); + + Entiers entiers = new Entiers(5); + entiers.inserer(3); + entiers.inserer(1); + entiers.inserer(5); + + Liste liste = new Liste(); + liste.inserer(3); + liste.inserer(1); + liste.inserer(5); + + for (int i = 0; i < 10; i++) { + affichable[i] = entiers; + affichable[i].afficher(); + + affichable[i] = liste; + affichable[i].afficher(); + + affichable[i] = new Segment(p1, p2); + affichable[i].afficher(); + + affichable[i] = new Cercle(p3, 5.5); + affichable[i].afficher(); + } + + } + + public static void main4() { + + Structure[] structure = new Structure[10]; + + Point p1 = new Point(1, 2); + Point p2 = new Point(2, 7); + Point p3 = new Point(1, 5); + Point p4 = new Point(3, 1); + + Segment segment1 = new Segment(p1, p2); + Segment segment2 = new Segment(p3, p4); + Cercle cercle = new Cercle(p3, 5.5); + Image image = new Image(); + image.ajouter(segment1); + image.ajouter(segment2); + image.ajouter(cercle); + + Entiers entiers = new Entiers(5); + entiers.inserer(3); + entiers.inserer(1); + entiers.inserer(4); + + Liste liste = new Liste(); + liste.inserer(3); + liste.inserer(1); + liste.inserer(5); + liste.inserer(4); + + for (int i = 0; i < 10; i++) { + structure[i] = entier; + structure[i].afficher(); + structure[i].compacter(1); + structure[i].afficher(); + + structure[i] = liste; + structure[i].afficher(); + structure[i].compacter(1); + structure[i].afficher(); + + structure[i] = image; + structure[i].afficher(); + structure[i].compacter(1); + structure[i].afficher(); + } + } + public static void main(String[] args) { - main2(); + main4(); }