Use a Main class for the main().
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 3 Apr 2018 09:36:36 +0000 (11:36 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 3 Apr 2018 09:36:36 +0000 (11:36 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
exo1/Makefile
exo1/Pile.java

index e09b2a36a9c722dbe6597980e4fd97ea7d2cc20c..b9cde1b4d1f50504ea47a18bc208c164b747c4d5 100644 (file)
@@ -46,13 +46,14 @@ JVM = java
 # NAME = Camilo        Juan
 
 CLASSES = \
-        Pile.java
+               Pile.java \
+               Main.java
 
 #
 # MAIN is a variable with the name of the file containing the main method
 #
 
-MAIN = Pile
+MAIN = Main
 
 #
 # the default make target entry
index 74998e44a976cc02048fab22ae29cf49998bb993..d69668a952f3cb4434972c200dfe9b257c0d128f 100644 (file)
@@ -36,7 +36,7 @@ public class Pile<E> {
      * get the stack head current index
      * @return the integer stack head index
      */
-    private int getHeadIndex() {
+    public int getHeadIndex() {
         return stack_head_index;
     }
 
@@ -113,61 +113,4 @@ public class Pile<E> {
         }
     }
 
-    /**
-     * 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();
-    }
 }