Add Main.java file for real.
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 3 Apr 2018 09:45:44 +0000 (11:45 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 3 Apr 2018 09:45:44 +0000 (11:45 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
exo1/Main.java [new file with mode: 0644]

diff --git a/exo1/Main.java b/exo1/Main.java
new file mode 100644 (file)
index 0000000..5efe910
--- /dev/null
@@ -0,0 +1,83 @@
+
+class Main {
+
+    /**
+     * The main() function
+     * @param String[] args main() function arguments array
+     */
+    public static void main(String[] args) {
+        Pile<Integer> stack = new Pile<Integer>(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<String> stackStr = new Pile<String>(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<String> stackStrDeq = new ArrayDeque<String>();
+        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());
+
+    }
+}