6 private int int_array
[];
7 private int array_size
;
8 private int stack_head_index
;
11 * set the size of the internal array
12 * @param int size the size of the array
14 private void setSize(int size
) {
19 * get the size of the internal array
20 * @return the integer size of the internal array
22 private int getSize() {
27 * set the stack head index
28 * @param int index the stack head index
30 private void setHeadIndex(int index
) {
31 stack_head_index
= index
;
35 * get the stack head current index
36 * @return the integer stack head index
38 private int getHeadIndex() {
39 return stack_head_index
;
44 * @param int size [description]
47 int_array
= new int[size
];
53 * [empiler description]
54 * @param int value [description]
56 public void empiler(int value
) {
58 int_array
[stack_head_index
] = value
;
61 System
.out
.println("La pile est pleine");
66 * [depiler description]
67 * @return [description]
69 public int depiler() {
72 return int_array
[stack_head_index
];
80 * @return [description]
82 private boolean plein() {
83 return (getHeadIndex() >= getSize());
88 * @return [description]
90 private boolean vide() {
91 return (getHeadIndex() == 0);
95 * [afficher description]
97 public void afficher() {
98 for (int i
= 0; i
< getHeadIndex(); i
++) {
99 System
.out
.println("element " + i
+ " " + int_array
[i
]);
104 * The main() function
105 * @param String[] args main() function arguments array
107 public static void main(String
[] args
) {
108 Pile stack
= new Pile(5);
118 System
.out
.println("Stack index " + stack
.getHeadIndex());
119 System
.out
.println("Stack head value " + stack
.depiler());
120 System
.out
.println("Stack index " + stack
.getHeadIndex());
121 System
.out
.println("Stack head value " + stack
.depiler());
122 System
.out
.println("Stack index " + stack
.getHeadIndex());
123 System
.out
.println("Stack head value " + stack
.depiler());
124 System
.out
.println("Stack index " + stack
.getHeadIndex());
125 System
.out
.println("Stack head value " + stack
.depiler());
126 System
.out
.println("Stack index " + stack
.getHeadIndex());
127 System
.out
.println("Stack head value " + stack
.depiler());
128 System
.out
.println("Stack index " + stack
.getHeadIndex());
129 System
.out
.println("Stack head value " + stack
.depiler());
130 System
.out
.println("Stack index " + stack
.getHeadIndex());