hell + gui
This commit is contained in:
parent
4a63c7c01e
commit
b05b7cd13c
9 changed files with 212 additions and 3 deletions
41
universe/Stack.java
Normal file
41
universe/Stack.java
Normal file
|
@ -0,0 +1,41 @@
|
|||
// Antoine CRETUAL, Lukian LEIZOUR, 21/02/2024
|
||||
|
||||
package universe;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
public class Stack <T> {
|
||||
// Atributes
|
||||
|
||||
private Vector <T> array;
|
||||
|
||||
// Construcors
|
||||
|
||||
public Stack() {
|
||||
array = new Vector<T>();
|
||||
}
|
||||
|
||||
public Stack(Vector<T> array) {
|
||||
array = array;
|
||||
}
|
||||
|
||||
// Methods
|
||||
|
||||
public void push(T x) {
|
||||
this.array.add(this.array.size(), x);
|
||||
}
|
||||
|
||||
public T pop() {
|
||||
T x = this.array.elementAt(this.array.size() - 1);
|
||||
this.array.remove(this.array.size() - 1);
|
||||
return x;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return this.array.size();
|
||||
}
|
||||
|
||||
public Stack copy() {
|
||||
return new Stack(new Vector<T>(this.array));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue