Repository navigation
Expand file tree
/
Copy pathMain.java
More file actions
58 lines (52 loc) · 1.98 KB
/
Copy pathMain.java
File metadata and controls
58 lines (52 loc) · 1.98 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int opcao;
int tamanhopilha = 0;
Pilha p = new Pilha(tamanhopilha);
Scanner teclado = new Scanner(System.in);
do {
System.out.println("\n:: Menu");
System.out.println(" 0 - Sair");
System.out.println(" 1 - Mostrar tamanho");
System.out.println(" 2 - Adicionar dado" );
System.out.println(" 3 - Remover dado" );
System.out.print("\n Opcao? ");
opcao = teclado.nextInt();
teclado.nextLine();
switch (opcao) {
case 0:
System.out.println("\n Tmj patrao");
break;
case 1:
if (p.isEmpty() == true) {
System.out.println("A pilha esta vazia");
} else if (p.isFull() == true) {
System.out.println("A pilha esta cheia");
} else {
System.out.print("A pilha tem " + tamanhopilha + " posicoes");
}
break;
case 2:
if (p.isFull() == false) {
tamanhopilha++;
System.out.println("Digite a String? ");
String texto = teclado.nextLine();
p.push(texto);
} else {System.out.println("A pilha esta cheia ");}
break;
case 3:
if (p.isEmpty() == true) {
System.out.println("A pilha esta vazia");
} else {
p.pop();
tamanhopilha--;
}
break;
default:
System.out.println("\n Opa, errou fera!");
break;
}
} while (opcao != 0);
}
}