* get the stack head current index
* @return the integer stack head index
*/
- private int getHeadIndex() {
+ public int getHeadIndex() {
return stack_head_index;
}
}
}
- /**
- * 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();
- }
}