Advertisement
Guest User

Untitled

a guest
Mar 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.04 KB | None | 0 0
  1. package Biblioteca;
  2.  
  3. import java.util.InputMismatchException;
  4. import java.util.Scanner;
  5.  
  6. public class Inicio
  7. {
  8. private static Scanner sc;
  9. public static void main(String[] args)
  10. {
  11. sc = new Scanner(System.in);
  12. boolean salir = false;
  13. int opcion;
  14. String a = "", b= "", c= "", d= "", e= "", f= "", g= "";
  15.  
  16. //creamos los 2 objetos de libros
  17. Libro libro1 = new Libro(a, b, c, d);
  18. Libro libro2 = new Libro(a, b, c, d);
  19.  
  20. //creamos los 2 objetos de socios
  21. Socio socio1 = new Socio(e, f, g);
  22. Socio socio2 = new Socio(e, f, g);
  23.  
  24. //creamos el menu
  25. while (!salir)
  26. {
  27.  
  28. System.out.println();
  29. System.out.println("1. Crear datos de libros");
  30. System.out.println("2. Crear datos de socios");
  31. System.out.println("3. Modificar datos libros");
  32. System.out.println("4. Modificar datos socios");
  33. System.out.println("5. Ver datos");
  34. System.out.println("6. Salir");
  35. System.out.println();
  36.  
  37. try {
  38. System.out.println("Escribe una de las opciones");
  39. opcion = sc.nextInt();
  40.  
  41. switch (opcion) {
  42. case 1:
  43. sc.nextLine();
  44. System.out.println("Has seleccionado la opcion 1");
  45. System.out.println();
  46. if (libro1.getISBN() == "" && libro2.getISBN() == "")
  47. {
  48. System.out.print("Introduzca ISBN: ");
  49. a = sc.nextLine();
  50. System.out.print("Introduzca Autor: ");
  51. b = sc.nextLine();
  52. System.out.print("Introduzca Páginas: ");
  53. c = sc.nextLine();
  54. System.out.print("Introduzca Editorial: ");
  55. d = sc.nextLine();
  56. libro1 = new Libro(a, b, c, d);
  57.  
  58. System.out.println();
  59. System.out.print("Introduzca ISBN: ");
  60. a = sc.nextLine();
  61. System.out.print("Introduzca Autor: ");
  62. b = sc.nextLine();
  63. System.out.print("Introduzca Páginas: ");
  64. c = sc.nextLine();
  65. System.out.print("Introduzca Editorial: ");
  66. d = sc.nextLine();
  67. libro2 = new Libro(a, b, c, d);
  68. }
  69. else
  70. {
  71. System.out.print("Ya existen los libros");
  72. }
  73.  
  74.  
  75. break;
  76. case 2:
  77. sc.nextLine();
  78. System.out.println("Has seleccionado la opcion 2");
  79. System.out.println();
  80. if (socio1.getDNI() == "" && socio2.getDNI() == "")
  81. {
  82. System.out.print("Introduzca DNI: ");
  83. e = sc.nextLine();
  84. System.out.print("Introduzca Nombre: ");
  85. f = sc.nextLine();
  86. System.out.print("Introduzca Apellido: ");
  87. g = sc.nextLine();
  88. socio1 = new Socio(e, f, g);
  89.  
  90. System.out.println();
  91. System.out.print("Introduzca DNI: ");
  92. e = sc.nextLine();
  93. System.out.print("Introduzca Nombre: ");
  94. f = sc.nextLine();
  95. System.out.print("Introduzca Apellido: ");
  96. g = sc.nextLine();
  97. socio2 = new Socio(e, f, g);
  98. }
  99. else
  100. {
  101. System.out.print("Ya existen los socios");
  102. }
  103. break;
  104. case 3:
  105. sc.nextLine();
  106. System.out.println("Has seleccionado la opcion 3");
  107. System.out.println("Indique el ISBN a modificar datos");
  108. a = sc.nextLine();
  109. if (libro1.getISBN() == a)
  110. {
  111. System.out.print("Introduzca Autor: ");
  112. b = sc.nextLine();
  113. System.out.print("Introduzca Páginas: ");
  114. c = sc.nextLine();
  115. System.out.print("Introduzca Editorial: ");
  116. d = sc.nextLine();
  117. libro2 = new Libro(a, b, c, d);
  118. }
  119. else if (libro2.getISBN() == a)
  120. {
  121. System.out.print("Introduzca Autor: ");
  122. b = sc.nextLine();
  123. System.out.print("Introduzca Páginas: ");
  124. c = sc.nextLine();
  125. System.out.print("Introduzca Editorial: ");
  126. d = sc.nextLine();
  127. libro2 = new Libro(a, b, c, d);
  128. }
  129. else
  130. {
  131. System.out.println("el librto no existe");
  132. }
  133. break;
  134. case 4:
  135. sc.nextLine();
  136. System.out.println("Has seleccionado la opcion 4");
  137. System.out.println("Indique el DNI a modificar datos");
  138. e = sc.nextLine();
  139. if (e == socio1.getDNI())
  140. {
  141. System.out.print("Introduzca Nombre: ");
  142. f = sc.nextLine();
  143. System.out.print("Introduzca Apellido: ");
  144. g = sc.nextLine();
  145. socio1 = new Socio(e, f, g);
  146. }
  147. else if (socio2.getDNI() == e)
  148. {
  149. System.out.print("Introduzca Nombre: ");
  150. f = sc.nextLine();
  151. System.out.print("Introduzca Apellido: ");
  152. g = sc.nextLine();
  153. socio2 = new Socio(e, f, g);
  154. }
  155. else
  156. {
  157. System.out.println("el socio no existe");
  158. }
  159. break;
  160. case 5:
  161. System.out.println("Has seleccionado la opcion 5");
  162. if (libro1.getISBN() == "")
  163. {
  164. System.out.println("Falta el libro 1");
  165. }
  166. if (libro2.getISBN() == "")
  167. {
  168. System.out.println("Falta el libro 2");
  169. }
  170. if (socio1.getDNI() == "")
  171. {
  172. System.out.println("Falta el socio 1");
  173. }
  174. if (socio2.getDNI() == "")
  175. {
  176. System.out.println("Falta el socio 2");
  177. }
  178. System.out.println(libro1.toString());
  179. System.out.println(libro2.toString());
  180. System.out.println(socio1.toString());
  181. System.out.println(socio2.toString());
  182. break;
  183. case 6:
  184. System.out.println("Has seleccionado la opcion salir");
  185. salir = true;
  186. break;
  187. default:
  188. System.out.println("Solo números entre 1 y 6");
  189. }
  190. } catch (InputMismatchException ex)
  191. {
  192. System.out.println("Debes insertar un número");
  193. sc.next();
  194. }
  195. }
  196. }
  197. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement