import
java.util.*;
02 | public class Cola { |
03 | public static void main( String args[] ){ |
04 | Scanner leer = new Scanner(System.in); |
05 |
06 | colagenerica obj = new colagenerica(); |
07 |
08 | int op; |
09 | int num; |
10 |
11 | do { |
12 | menu(); |
13 | op = leer.nextInt(); |
14 |
15 | switch (op){ |
16 | case 1 : |
17 | System.out.println( "Numero a insertar" ); |
18 | num = leer.nextInt(); |
19 | if (obj.inscola(num)){ |
20 | System.out.println( "fre" +obj.fre+ "fin" +obj.fin+ "aux" +obj.max ); |
21 | System.out.println( "El numero " +num+ " se inserto en la cola [" +obj.dret+ "]" ); |
22 | System.out.println(); |
23 | } |
24 | else { |
25 | System.out.println( "Cola llena" ); |
26 | } |
27 | break ; |
28 | case 2 : |
29 | if (obj.retcola()){ |
30 | System.out.println( "El dato retirado fue: " +obj.dret ); |
31 | } |
32 | else { |
33 | System.out.println( "Cola vacia" ); |
34 | } |
35 | break ; |
36 | case 3 : |
37 | if (obj.fre==- 1 && obj.fin==- 1 ){ |
38 | System.out.println( "Cola vacia" ); |
39 | } |
40 | else { |
41 | System.out.println( "Estado de la cola:" ); |
42 | for ( int i=obj.fre; i<=obj.fin; i++){ |
43 | System.out.print(obj.c[i]+ " \t" ); |
44 | } |
45 | break ; |
46 | } |
47 | } |
48 | } |
49 | while (op != 4 ); |
50 | } |
51 |
52 | public static void menu(){ |
53 | System.out.println( "\t Menu para colas \n" ); |
54 | System.out.println( "1.- Insertar" ); |
55 | System.out.println( "2.- Retirar" ); |
56 | System.out.println( "3.- Estado" ); |
57 | System.out.println( "4.- Fin" ); |
58 | System.out.println( "\n Selecciona" ); |
59 | } |
60 | } |
No hay comentarios:
Publicar un comentario