From: Jérôme Benoit Date: Thu, 15 Feb 2018 14:49:00 +0000 (+0100) Subject: Structure: fix all remaining bugs and a test case. X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=bc54daba66a9e9c4fc7095a4f78ff483cdff30cf;p=TP_POO.git Structure: fix all remaining bugs and a test case. Signed-off-by: Jérôme Benoit --- diff --git a/Structure/Entiers.java b/Structure/Entiers.java index b2c9247..4abf4f0 100644 --- a/Structure/Entiers.java +++ b/Structure/Entiers.java @@ -97,9 +97,9 @@ class Entiers extends Structure { } public void afficher() { - System.out.println("----"); + System.out.println("---- entiers ----"); for (int i = 0; i < getCurrentSize(); i++) { - System.out.println("element " + i + " " + int_array[i]); + System.out.println("element " + i + " : " + int_array[i]); } } diff --git a/Structure/Liste.java b/Structure/Liste.java index d6bd963..b31d081 100644 --- a/Structure/Liste.java +++ b/Structure/Liste.java @@ -118,19 +118,20 @@ public class Liste extends Structure { } public void afficher() { + System.out.println("---- liste ----"); if (isEmpty()) { System.out.println("Liste vide"); } else if (headNode.getNext() == null) { - System.out.println("Valeur du noeud 0 : " + headNode.getData()); + System.out.println("element 0 : " + headNode.getData()); } else { IntNode nodeCursor = headNode; int i = 0; while (nodeCursor.getNext() != null) { - System.out.println("Valeur du noeud " + i + " : " + nodeCursor.getData()); + System.out.println("element " + i + " : " + nodeCursor.getData()); nodeCursor = nodeCursor.getNext(); i++; } - System.out.println("Valeur du noeud " + i++ + " : " + nodeCursor.getData()); + System.out.println("element " + i++ + " : " + nodeCursor.getData()); } } diff --git a/Structure/Main.java b/Structure/Main.java index de10882..3794bdd 100644 --- a/Structure/Main.java +++ b/Structure/Main.java @@ -67,8 +67,25 @@ class Main { public static void main(String[] args) { - main_liste(); - main_entiers(); + Structure[] structure = new Structure[10]; + + for (int i = 0; i < 10; i++) { + structure[i] = new Liste(); + structure[i].inserer(3); + structure[i].inserer(1); + structure[i].inserer(5); + structure[i].afficher(); + structure[i].supprimer(5); + structure[i].afficher(); + + structure[i] = new Entiers(10); + structure[i].inserer(3); + structure[i].inserer(1); + structure[i].inserer(5); + structure[i].afficher(); + structure[i].supprimer(5); + structure[i].afficher(); + } }