Skip to content

Commit 8d38bb3

Browse files
authored
Create ListasEnlazadas
1 parent 1f6b699 commit 8d38bb3

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

Examencito/ListasEnlazadas

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package Listas_enlazadas;
2+
import java.util.Random;
3+
public class Pilas {
4+
private ListaEnlazada Esquina;
5+
private int indice;
6+
private Nodo Inicio;
7+
private Nodo Fin;
8+
private int NoElementos;
9+
int length;
10+
//Constructor completo
11+
public Pilas (int n){
12+
//n es la cantidad de elementos que puede guardad la pila.
13+
//Esquina = new int [n];
14+
NoElementos = 0;
15+
Esquina = new ListaEnlazada();
16+
}
17+
18+
public int cantidad(){
19+
return NoElementos;
20+
}
21+
22+
public void apilar (int num)throws DesbordamientoPila{
23+
/*if (this.llena()){
24+
throw new DesbordamientoPila();
25+
}*/
26+
//Random num = new Random();
27+
Esquina.agregarAlFin(new Nodo(null, num));
28+
//Esquina = numero;
29+
NoElementos++;
30+
31+
}
32+
33+
public int sacar() throws SubdesbordamientoPila{
34+
if (this.vacia()){
35+
throw new SubdesbordamientoPila();
36+
}
37+
int esacar;
38+
esacar = NoElementos-1;
39+
NoElementos--;
40+
//indice--;
41+
//esacar = Esquina[indice];
42+
//las ultimas 2 lineas sustituyen a las dos ultimas.
43+
return esacar;
44+
}
45+
46+
//Evaluar cuando la pila esta vacia
47+
public boolean vacia(){
48+
if (NoElementos == 0){
49+
return true;
50+
}
51+
return false;
52+
}
53+
/*
54+
//Evaluar cuando la pila esta llena
55+
public boolean llena(){
56+
if (NoElementos == Esquina.length){
57+
return true;
58+
}
59+
return false;
60+
}
61+
62+
public int capacidad (){
63+
return Esquina.length;
64+
}
65+
*/
66+
67+
}

0 commit comments

Comments
 (0)