6 private int[] int_array
;
7 private int array_size
;
8 private int head_index
;
12 * @param int size [description]
15 int_array
= new int[size
];
21 * set the size of the internal array
22 * @param int size the size of the array
24 private void setSize(int size
) {
29 * get the size of the internal array
30 * @return the integer size of the internal array
32 private int getSize() {
37 * set the stack head index
38 * @param int index the stack head index
40 private void setHeadIndex(int index
) {
45 * get the stack head current index
46 * @return the integer stack head index
48 private int getHeadIndex() {
53 * [empiler description]
54 * @param int value [description]
56 public void empiler(int value
) {
58 int_array
[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
[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());