Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package herencia.y.polimorfismo.futbol;
- import static herencia.y.polimorfismo.futbol.Main.integrantes;
- import java.util.ArrayList;
- import java.util.InputMismatchException;
- import java.util.Scanner;
- /**
- *
- * @author Terra Suzuki
- */
- public class Main2 {
- /**
- * ArrayList de objetos SeleccionFutbol
- * Independientemente de la clase hija a la que pertenezca el objeto
- */
- public static ArrayList<SeleccionFutbol> integrantes = new ArrayList<SeleccionFutbol>();
- public static void main(String[] args) {
- int nf = 0;
- int nm = 0;
- int sel = 0;
- int i = 0;
- int ne = 0;
- SeleccionFutbol[] EqFut = new Futbolista[nf];
- SeleccionFutbol[] EqMas = new Masajista[nm];
- SeleccionFutbol Entrenador = new Entrenador();
- Scanner x = new Scanner (System.in);
- while(sel!=9){
- System.out.println("Menu. ");
- System.out.println("1)Capturar Datos: ");
- System.out.println("2) Datos De Concentracion: ");
- System.out.println("3) Datos De Viaje: ");
- System.out.println("4) Datos De entenamiento: ");
- System.out.println("5) Datos De Partido De Futbol: ");
- System.out.println("6) Datos De La Planificacion Del Entrenamiento: ");
- System.out.println("7) Datos De Entrevista: ");
- System.out.println("8) Datos De Dar Masaje: ");
- System.out.println("9) Salir: ");
- sel=x.nextInt();
- switch(sel){
- case 1:
- System.out.println("Ingrese Datos De Entrenador: ");
- try{
- System.out.println("Ingrese Id: ");
- Entrenador.setId(x.nextInt());
- }
- catch(InputMismatchException e ){
- System.out.println("Debe ingresar solo numeros enteros...");
- }
- System.out.println("Ingrese Nombre: ");
- Entrenador.setNombre(x.next());
- System.out.println("Ingrese Apellido: ");
- Entrenador.setApellidos(x.next());
- System.out.println("Ingrese Edad: ");
- Entrenador.setEdad(x.nextInt());
- System.out.println("Ingrese Codigo De Federacion: ");
- ((Entrenador)Entrenador).setIdFederacion(x.next());
- System.out.println("Ingresar Cantidad De Futbolistas: ");
- nf=x.nextInt();
- for(i=0;i<nf;i++){
- ne = i+1;
- System.out.println("Ingrese Datos Del Futbolista "+ne+": ");
- try{
- System.out.print("Ingrese Id: "+" ");
- EqFut[nf].setId(x.nextInt());
- }
- catch(InputMismatchException e ){
- System.out.println("Debe ingresar solo numeros enteros...");
- }
- System.out.print("Ingrese Nombre: "+" ");
- EqFut[i].setNombre(x.next());
- System.out.print("Ingrese Apellido: "+" ");
- EqFut[i].setApellidos(x.next());
- System.out.print("Ingrese Edad: "+" ");
- EqFut[i].setEdad(x.nextInt());
- System.out.print("Ingrese Demarcacion: "+" ");
- ((Futbolista)EqFut[i]).setDemarcacion(x.next());
- System.out.print("Ingrese Dorsal: "+" ");
- ((Futbolista)EqFut[i]).setDorsal(x.nextInt());
- }
- System.out.println("Ingresar Cantidad De Masajistas: ");
- nm=x.nextInt();
- ne=0;
- for(i=0;i<nm;i++){
- ne = i + 1;
- System.out.println("Ingrese Datos Del Masajista "+ne+": ");
- System.out.println("Ingrese Id: ");
- EqMas[i].setId(x.nextInt());
- System.out.println("Ingrese Nombre: ");
- EqMas[i].setNombre(x.next());
- System.out.println("Ingrese Apellido: ");
- EqMas[i].setApellidos(x.next());
- System.out.println("Ingrese Edad: ");
- EqMas[i].setEdad(x.nextInt());
- System.out.println("Ingrese Profesion: ");
- ((Masajista)EqMas[i]).setTitulacion(x.next());
- System.out.println("Años De Experiencia: ");
- ((Masajista)EqMas[i]).setAniosExperiencia(x.nextInt());
- }
- // Se añaden a todos los integrantes al arreglo
- integrantes.add(Entrenador);
- for(i=0; i<nf; i++){
- integrantes.add(EqFut[i]);
- }
- for(i=0; i<nm; i++){
- integrantes.add(EqMas[i]);
- }
- break;
- case 2:
- System.out.println("Todos los integrantes comienzan una concentracion.");
- for (SeleccionFutbol integrante : integrantes) {
- System.out.print(integrante.getNombre()+" "+integrante.getApellidos()+" -> ");
- integrante.Concentrarse();
- }
- break;
- case 3:
- System.out.println("\nTodos los integrantes viajan para jugar un partido...");
- for (SeleccionFutbol integrante : integrantes){
- System.out.print(integrante.getNombre()+" "+integrante.getApellidos()+" -> ");
- integrante.Viajar();
- }
- break;
- case 4:
- System.out.println("\nEntrenamiento: Todos los integrantes tienen su función en un entrenamiento");
- for (SeleccionFutbol integrante : integrantes) {
- System.out.print(integrante.getNombre() + " " + integrante.getApellidos() + " -> ");
- integrante.entrenamiento();
- }
- break;
- case 5:
- System.out.println("\nPartido de Fútbol: Todos los integrantes tienen su función en un partido");
- for (SeleccionFutbol integrante : integrantes) {
- System.out.print(integrante.getNombre() + " " + integrante.getApellidos() + " -> ");
- integrante.partidoFutbol();
- }
- break;
- case 6:
- System.out.println("\nPlanificar Entrenamiento: Solo el entrenador tiene el método para planificar un entrenamiento:");
- System.out.print(Entrenador.getNombre() + " " + Entrenador.getApellidos() + " -> ");
- ((Entrenador) Entrenador).planificarEntrenamiento();
- break;
- case 7:
- System.out.println("\nEntrevista: Solo el futbolista tiene el método para dar una entrevista:");
- System.out.print(EqFut[i].getNombre() + " " + EqFut[i].getApellidos() + " -> ");
- ((Futbolista) EqFut[i]).entrevista();
- break;
- case 8:
- System.out.println("\nMasaje: Solo el masajista tiene el método para dar un masaje:");
- System.out.print(EqMas[i].getNombre() + " " + EqMas[i].getApellidos() + " -> ");
- ((Masajista)EqMas[i]).darMasaje();
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement