Advertisement
terrasuzuki

La wea fome impakta al Marqui

May 27th, 2015
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.93 KB | None | 0 0
  1. package herencia.y.polimorfismo.futbol;
  2.  
  3. import static herencia.y.polimorfismo.futbol.Main.integrantes;
  4. import java.util.ArrayList;
  5. import java.util.InputMismatchException;
  6. import java.util.Scanner;
  7.  
  8. /**
  9. *
  10. * @author Terra Suzuki
  11. */
  12. public class Main2 {
  13.  
  14. /**
  15. * ArrayList de objetos SeleccionFutbol
  16. * Independientemente de la clase hija a la que pertenezca el objeto
  17. */
  18.  
  19. public static ArrayList<SeleccionFutbol> integrantes = new ArrayList<SeleccionFutbol>();
  20.  
  21. public static void main(String[] args) {
  22.  
  23. int nf = 0;
  24. int nm = 0;
  25. int sel = 0;
  26. int i = 0;
  27. int ne = 0;
  28.  
  29. SeleccionFutbol[] EqFut = new Futbolista[nf];
  30. SeleccionFutbol[] EqMas = new Masajista[nm];
  31. SeleccionFutbol Entrenador = new Entrenador();
  32.  
  33. Scanner x = new Scanner (System.in);
  34.  
  35. while(sel!=9){
  36. System.out.println("Menu. ");
  37. System.out.println("1)Capturar Datos: ");
  38. System.out.println("2) Datos De Concentracion: ");
  39. System.out.println("3) Datos De Viaje: ");
  40. System.out.println("4) Datos De entenamiento: ");
  41. System.out.println("5) Datos De Partido De Futbol: ");
  42. System.out.println("6) Datos De La Planificacion Del Entrenamiento: ");
  43. System.out.println("7) Datos De Entrevista: ");
  44. System.out.println("8) Datos De Dar Masaje: ");
  45. System.out.println("9) Salir: ");
  46. sel=x.nextInt();
  47.  
  48. switch(sel){
  49.  
  50. case 1:
  51.  
  52. System.out.println("Ingrese Datos De Entrenador: ");
  53.  
  54. try{
  55. System.out.println("Ingrese Id: ");
  56. Entrenador.setId(x.nextInt());
  57. }
  58. catch(InputMismatchException e ){
  59. System.out.println("Debe ingresar solo numeros enteros...");
  60. }
  61.  
  62. System.out.println("Ingrese Nombre: ");
  63. Entrenador.setNombre(x.next());
  64.  
  65. System.out.println("Ingrese Apellido: ");
  66. Entrenador.setApellidos(x.next());
  67.  
  68. System.out.println("Ingrese Edad: ");
  69. Entrenador.setEdad(x.nextInt());
  70.  
  71. System.out.println("Ingrese Codigo De Federacion: ");
  72. ((Entrenador)Entrenador).setIdFederacion(x.next());
  73.  
  74. System.out.println("Ingresar Cantidad De Futbolistas: ");
  75. nf=x.nextInt();
  76.  
  77. for(i=0;i<nf;i++){
  78.  
  79. ne = i+1;
  80. System.out.println("Ingrese Datos Del Futbolista "+ne+": ");
  81.  
  82. try{
  83. System.out.print("Ingrese Id: "+" ");
  84. EqFut[nf].setId(x.nextInt());
  85. }
  86. catch(InputMismatchException e ){
  87. System.out.println("Debe ingresar solo numeros enteros...");
  88. }
  89.  
  90. System.out.print("Ingrese Nombre: "+" ");
  91. EqFut[i].setNombre(x.next());
  92.  
  93. System.out.print("Ingrese Apellido: "+" ");
  94. EqFut[i].setApellidos(x.next());
  95.  
  96. System.out.print("Ingrese Edad: "+" ");
  97. EqFut[i].setEdad(x.nextInt());
  98.  
  99. System.out.print("Ingrese Demarcacion: "+" ");
  100. ((Futbolista)EqFut[i]).setDemarcacion(x.next());
  101.  
  102. System.out.print("Ingrese Dorsal: "+" ");
  103. ((Futbolista)EqFut[i]).setDorsal(x.nextInt());
  104.  
  105. }
  106.  
  107. System.out.println("Ingresar Cantidad De Masajistas: ");
  108. nm=x.nextInt();
  109.  
  110. ne=0;
  111.  
  112. for(i=0;i<nm;i++){
  113.  
  114. ne = i + 1;
  115. System.out.println("Ingrese Datos Del Masajista "+ne+": ");
  116.  
  117. System.out.println("Ingrese Id: ");
  118. EqMas[i].setId(x.nextInt());
  119.  
  120. System.out.println("Ingrese Nombre: ");
  121. EqMas[i].setNombre(x.next());
  122.  
  123. System.out.println("Ingrese Apellido: ");
  124. EqMas[i].setApellidos(x.next());
  125.  
  126. System.out.println("Ingrese Edad: ");
  127. EqMas[i].setEdad(x.nextInt());
  128.  
  129. System.out.println("Ingrese Profesion: ");
  130. ((Masajista)EqMas[i]).setTitulacion(x.next());
  131.  
  132. System.out.println("Años De Experiencia: ");
  133. ((Masajista)EqMas[i]).setAniosExperiencia(x.nextInt());
  134.  
  135. }
  136.  
  137. // Se añaden a todos los integrantes al arreglo
  138. integrantes.add(Entrenador);
  139.  
  140. for(i=0; i<nf; i++){
  141. integrantes.add(EqFut[i]);
  142. }
  143.  
  144. for(i=0; i<nm; i++){
  145. integrantes.add(EqMas[i]);
  146. }
  147. break;
  148.  
  149.  
  150. case 2:
  151.  
  152. System.out.println("Todos los integrantes comienzan una concentracion.");
  153.  
  154. for (SeleccionFutbol integrante : integrantes) {
  155. System.out.print(integrante.getNombre()+" "+integrante.getApellidos()+" -> ");
  156. integrante.Concentrarse();
  157. }
  158. break;
  159.  
  160.  
  161. case 3:
  162.  
  163. System.out.println("\nTodos los integrantes viajan para jugar un partido...");
  164.  
  165. for (SeleccionFutbol integrante : integrantes){
  166. System.out.print(integrante.getNombre()+" "+integrante.getApellidos()+" -> ");
  167. integrante.Viajar();
  168. }
  169. break;
  170.  
  171.  
  172. case 4:
  173.  
  174. System.out.println("\nEntrenamiento: Todos los integrantes tienen su función en un entrenamiento");
  175.  
  176. for (SeleccionFutbol integrante : integrantes) {
  177. System.out.print(integrante.getNombre() + " " + integrante.getApellidos() + " -> ");
  178. integrante.entrenamiento();
  179. }
  180. break;
  181.  
  182.  
  183. case 5:
  184.  
  185. System.out.println("\nPartido de Fútbol: Todos los integrantes tienen su función en un partido");
  186.  
  187. for (SeleccionFutbol integrante : integrantes) {
  188. System.out.print(integrante.getNombre() + " " + integrante.getApellidos() + " -> ");
  189. integrante.partidoFutbol();
  190. }
  191. break;
  192.  
  193.  
  194. case 6:
  195.  
  196. System.out.println("\nPlanificar Entrenamiento: Solo el entrenador tiene el método para planificar un entrenamiento:");
  197.  
  198. System.out.print(Entrenador.getNombre() + " " + Entrenador.getApellidos() + " -> ");
  199. ((Entrenador) Entrenador).planificarEntrenamiento();
  200.  
  201. break;
  202.  
  203.  
  204. case 7:
  205.  
  206. System.out.println("\nEntrevista: Solo el futbolista tiene el método para dar una entrevista:");
  207.  
  208. System.out.print(EqFut[i].getNombre() + " " + EqFut[i].getApellidos() + " -> ");
  209. ((Futbolista) EqFut[i]).entrevista();
  210.  
  211. break;
  212.  
  213. case 8:
  214.  
  215. System.out.println("\nMasaje: Solo el masajista tiene el método para dar un masaje:");
  216.  
  217. System.out.print(EqMas[i].getNombre() + " " + EqMas[i].getApellidos() + " -> ");
  218. ((Masajista)EqMas[i]).darMasaje();
  219.  
  220. break;
  221. }
  222.  
  223. }
  224.  
  225. }
  226.  
  227. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement