From bc54daba66a9e9c4fc7095a4f78ff483cdff30cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 15 Feb 2018 15:49:00 +0100 Subject: [PATCH] Structure: fix all remaining bugs and a test case. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- Structure/Entiers.java | 4 ++-- Structure/Liste.java | 7 ++++--- Structure/Main.java | 21 +++++++++++++++++++-- 3 files changed, 25 insertions(+), 7 deletions(-) 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(); + } } -- 2.34.1