Guest User

Untitled

a guest
Oct 16th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. package com.curso.presentacion;
  2.  
  3. import java.util.Scanner;
  4.  
  5. import com.curso.modelo.Persona;
  6. import com.curso.negocio.GestorAgenda;
  7.  
  8. public class AgendaConsola {
  9.  
  10. private Scanner sc = new Scanner(System.in);
  11. private GestorAgenda ga = new GestorAgenda();
  12.  
  13. private void mostrarMenu() {
  14. System.out.println("==========================");
  15. System.out.println("1- Insertar una persona");
  16. System.out.println("2- Modificar una persona");
  17. System.out.println("3- Borrar una persona");
  18. System.out.println("4- Listar la agenda");
  19. System.out.println("5- Salir");
  20. }
  21.  
  22. public void menuPrincipal(){
  23.  
  24. int opcion = 0;
  25.  
  26. do{
  27.  
  28. mostrarMenu();
  29.  
  30. opcion = sc.nextInt();
  31. sc.nextLine(); //Para vaciar el buffer del scanner que todavía tiene el salto de línea
  32.  
  33. switch(opcion){
  34. case 1: submenuInsertar();
  35. break;
  36. case 2:
  37. break;
  38. case 3: borrarPersona();
  39. break;
  40. case 4: listarAgenda();
  41. break;
  42. }
  43.  
  44.  
  45. }while(opcion!=5);
  46.  
  47. }
  48.  
  49. private void borrarPersona() {
  50. System.out.println("==========================");
  51. System.out.println("Seleccione la persona a borrar");
  52. ga.borrarPersona(null);
  53. }
  54.  
  55. private void listarAgenda() {
  56. System.out.println("==========================");
  57. Persona[] agenda = ga.listarAgenda();
  58. }
  59.  
  60. private void submenuInsertar() {
  61.  
  62. System.out.println("==========================");
  63. System.out.println("Introduzca el nombre de la persona:");
  64. String nombre = sc.nextLine();
  65. sc.nextLine();
  66.  
  67. Persona p = new Persona(nombre);
  68. ga.insertarPersona(p);
  69.  
  70. }
  71.  
  72.  
  73.  
  74.  
  75. }
Add Comment
Please, Sign In to add comment