From 271cd3c9ec9937bc24876e0258a2228ef4ce4299 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 3 Apr 2018 11:36:36 +0200 Subject: [PATCH] Use a Main class for the main(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- exo1/Makefile | 5 +++-- exo1/Pile.java | 59 +------------------------------------------------- 2 files changed, 4 insertions(+), 60 deletions(-) diff --git a/exo1/Makefile b/exo1/Makefile index e09b2a3..b9cde1b 100644 --- a/exo1/Makefile +++ b/exo1/Makefile @@ -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 diff --git a/exo1/Pile.java b/exo1/Pile.java index 74998e4..d69668a 100644 --- a/exo1/Pile.java +++ b/exo1/Pile.java @@ -36,7 +36,7 @@ public class Pile { * 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 { } } - /** - * 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(); - } } -- 2.34.1