From f5d81de24939c773ce72c5a1755791bce5cbf1a9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 3 Apr 2018 11:45:44 +0200 Subject: [PATCH] Add Main.java file for real. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- exo1/Main.java | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 exo1/Main.java diff --git a/exo1/Main.java b/exo1/Main.java new file mode 100644 index 0000000..5efe910 --- /dev/null +++ b/exo1/Main.java @@ -0,0 +1,83 @@ + +class Main { + + /** + * The main() function + * @param String[] args main() function arguments array + */ + public static void main(String[] args) { + Pile stack = new Pile(5); + + stack.empiler(3); + stack.empiler(5); + stack.empiler(4); + stack.empiler(7); + stack.empiler(8); + + stack.afficher(); + + System.out.println("Stack index " + stack.getHeadIndex()); + System.out.println("Stack head value " + stack.depiler()); + System.out.println("Stack index " + stack.getHeadIndex()); + System.out.println("Stack head value " + stack.depiler()); + System.out.println("Stack index " + stack.getHeadIndex()); + System.out.println("Stack head value " + stack.depiler()); + System.out.println("Stack index " + stack.getHeadIndex()); + System.out.println("Stack head value " + stack.depiler()); + System.out.println("Stack index " + stack.getHeadIndex()); + System.out.println("Stack head value " + stack.depiler()); + System.out.println("Stack index " + stack.getHeadIndex()); + System.out.println("Stack head value " + stack.depiler()); + System.out.println("Stack index " + stack.getHeadIndex()); + + stack.afficher(); + + Pile stackStr = new Pile(5); + + stackStr.empiler("Bonjour"); + stackStr.empiler("Salut"); + stackStr.empiler("Hello"); + stackStr.empiler("Hi"); + stackStr.empiler("Hugh"); + + stackStr.afficher(); + + System.out.println("Stack index " + stackStr.getHeadIndex()); + System.out.println("Stack head value " + stackStr.depiler()); + System.out.println("Stack index " + stackStr.getHeadIndex()); + System.out.println("Stack head value " + stackStr.depiler()); + System.out.println("Stack index " + stackStr.getHeadIndex()); + System.out.println("Stack head value " + stackStr.depiler()); + System.out.println("Stack index " + stackStr.getHeadIndex()); + System.out.println("Stack head value " + stackStr.depiler()); + System.out.println("Stack index " + stackStr.getHeadIndex()); + System.out.println("Stack head value " + stackStr.depiler()); + System.out.println("Stack index " + stackStr.getHeadIndex()); + System.out.println("Stack head value " + stackStr.depiler()); + System.out.println("Stack index " + stackStr.getHeadIndex()); + + stackStr.afficher(); + + ArrayDeque stackStrDeq = new ArrayDeque(); + stackStrDeq.push("Bonjour"); + stackStrDeq.push("Salut"); + stackStrDeq.push("Hello"); + stackStrDeq.push("Hi"); + stackStrDeq.push("Hugh"); + + System.out.println("Stack index " + stackStrDeq.size()); + System.out.println("Stack head value " + stackStrDeq.pop()); + System.out.println("Stack index " + stackStrDeq.size()); + System.out.println("Stack head value " + stackStrDeq.pop()); + System.out.println("Stack index " + stackStrDeq.size()); + System.out.println("Stack head value " + stackStrDeq.pop()); + System.out.println("Stack index " + stackStrDeq.size()); + System.out.println("Stack head value " + stackStrDeq.pop()); + System.out.println("Stack index " + stackStrDeq.size()); + System.out.println("Stack head value " + stackStrDeq.pop()); + System.out.println("Stack index " + stackStrDeq.size()); + System.out.println("Stack head value " + stackStrDeq.pop()); + System.out.println("Stack index " + stackStrDeq.size()); + + } +} -- 2.34.1