-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPilaE.java
More file actions
46 lines (38 loc) · 976 Bytes
/
Copy pathPilaE.java
File metadata and controls
46 lines (38 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import com.sun.corba.se.internal.Interceptors.PIORB;
/**
* Created by Paca on 3/14/14.
*/
public class PilaE implements Pila{
Object[] repositorio;
int index;
public PilaE(){
repositorio = new Object[10];
index = 0;
}
public void apilar(Object objectParaApilar){
if (index == repositorio.length){
agrandarRepositorio();
}
index++;
repositorio[index] = objectParaApilar;
}
public void desapilar(){
if (index >= 0){
index--;
}
}
public Object verTope(){
if (index >= 0){
return repositorio[index];
}else{
return null;
}
}
private void agrandarRepositorio(){
Object[] repositorioTemporario = new Object[index * 2];
for (int i = 0; i < repositorio.length ; i++) {
repositorioTemporario[i] = repositorio[i];
}
repositorio = repositorioTemporario;
}
}