Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Biblioteca;
- import java.util.InputMismatchException;
- import java.util.Scanner;
- public class Inicio
- {
- private static Scanner sc;
- public static void main(String[] args)
- {
- sc = new Scanner(System.in);
- boolean salir = false;
- int opcion;
- String a = "", b= "", c= "", d= "", e= "", f= "", g= "";
- //creamos los 2 objetos de libros
- Libro libro1 = new Libro(a, b, c, d);
- Libro libro2 = new Libro(a, b, c, d);
- //creamos los 2 objetos de socios
- Socio socio1 = new Socio(e, f, g);
- Socio socio2 = new Socio(e, f, g);
- //creamos el menu
- while (!salir)
- {
- System.out.println();
- System.out.println("1. Crear datos de libros");
- System.out.println("2. Crear datos de socios");
- System.out.println("3. Modificar datos libros");
- System.out.println("4. Modificar datos socios");
- System.out.println("5. Ver datos");
- System.out.println("6. Salir");
- System.out.println();
- try {
- System.out.println("Escribe una de las opciones");
- opcion = sc.nextInt();
- switch (opcion) {
- case 1:
- sc.nextLine();
- System.out.println("Has seleccionado la opcion 1");
- System.out.println();
- if (libro1.getISBN() == "" && libro2.getISBN() == "")
- {
- System.out.print("Introduzca ISBN: ");
- a = sc.nextLine();
- System.out.print("Introduzca Autor: ");
- b = sc.nextLine();
- System.out.print("Introduzca Páginas: ");
- c = sc.nextLine();
- System.out.print("Introduzca Editorial: ");
- d = sc.nextLine();
- libro1 = new Libro(a, b, c, d);
- System.out.println();
- System.out.print("Introduzca ISBN: ");
- a = sc.nextLine();
- System.out.print("Introduzca Autor: ");
- b = sc.nextLine();
- System.out.print("Introduzca Páginas: ");
- c = sc.nextLine();
- System.out.print("Introduzca Editorial: ");
- d = sc.nextLine();
- libro2 = new Libro(a, b, c, d);
- }
- else
- {
- System.out.print("Ya existen los libros");
- }
- break;
- case 2:
- sc.nextLine();
- System.out.println("Has seleccionado la opcion 2");
- System.out.println();
- if (socio1.getDNI() == "" && socio2.getDNI() == "")
- {
- System.out.print("Introduzca DNI: ");
- e = sc.nextLine();
- System.out.print("Introduzca Nombre: ");
- f = sc.nextLine();
- System.out.print("Introduzca Apellido: ");
- g = sc.nextLine();
- socio1 = new Socio(e, f, g);
- System.out.println();
- System.out.print("Introduzca DNI: ");
- e = sc.nextLine();
- System.out.print("Introduzca Nombre: ");
- f = sc.nextLine();
- System.out.print("Introduzca Apellido: ");
- g = sc.nextLine();
- socio2 = new Socio(e, f, g);
- }
- else
- {
- System.out.print("Ya existen los socios");
- }
- break;
- case 3:
- sc.nextLine();
- System.out.println("Has seleccionado la opcion 3");
- System.out.println("Indique el ISBN a modificar datos");
- a = sc.nextLine();
- if (libro1.getISBN() == a)
- {
- System.out.print("Introduzca Autor: ");
- b = sc.nextLine();
- System.out.print("Introduzca Páginas: ");
- c = sc.nextLine();
- System.out.print("Introduzca Editorial: ");
- d = sc.nextLine();
- libro2 = new Libro(a, b, c, d);
- }
- else if (libro2.getISBN() == a)
- {
- System.out.print("Introduzca Autor: ");
- b = sc.nextLine();
- System.out.print("Introduzca Páginas: ");
- c = sc.nextLine();
- System.out.print("Introduzca Editorial: ");
- d = sc.nextLine();
- libro2 = new Libro(a, b, c, d);
- }
- else
- {
- System.out.println("el librto no existe");
- }
- break;
- case 4:
- sc.nextLine();
- System.out.println("Has seleccionado la opcion 4");
- System.out.println("Indique el DNI a modificar datos");
- e = sc.nextLine();
- if (e == socio1.getDNI())
- {
- System.out.print("Introduzca Nombre: ");
- f = sc.nextLine();
- System.out.print("Introduzca Apellido: ");
- g = sc.nextLine();
- socio1 = new Socio(e, f, g);
- }
- else if (socio2.getDNI() == e)
- {
- System.out.print("Introduzca Nombre: ");
- f = sc.nextLine();
- System.out.print("Introduzca Apellido: ");
- g = sc.nextLine();
- socio2 = new Socio(e, f, g);
- }
- else
- {
- System.out.println("el socio no existe");
- }
- break;
- case 5:
- System.out.println("Has seleccionado la opcion 5");
- if (libro1.getISBN() == "")
- {
- System.out.println("Falta el libro 1");
- }
- if (libro2.getISBN() == "")
- {
- System.out.println("Falta el libro 2");
- }
- if (socio1.getDNI() == "")
- {
- System.out.println("Falta el socio 1");
- }
- if (socio2.getDNI() == "")
- {
- System.out.println("Falta el socio 2");
- }
- System.out.println(libro1.toString());
- System.out.println(libro2.toString());
- System.out.println(socio1.toString());
- System.out.println(socio2.toString());
- break;
- case 6:
- System.out.println("Has seleccionado la opcion salir");
- salir = true;
- break;
- default:
- System.out.println("Solo números entre 1 y 6");
- }
- } catch (InputMismatchException ex)
- {
- System.out.println("Debes insertar un número");
- sc.next();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement