|
| 1 | +package ejercicio09; |
| 2 | + |
| 3 | +import java.util.ArrayList; |
| 4 | + |
| 5 | +public class AndrewCodev { |
| 6 | + public static void main(String[] args) { |
| 7 | + Perro perro = new Perro(null, null); |
| 8 | + perro.setNombre("Pluto"); |
| 9 | + perro.setRaza("Labrador"); |
| 10 | + perro.ladra(); |
| 11 | + |
| 12 | + System.out.println(perro.getNombre() + " - " + perro.getRaza() + " - " + perro.ladra()); |
| 13 | + Gato gato = new Gato(null, null); |
| 14 | + gato.setNombre("Tom"); |
| 15 | + gato.setRaza("Persa"); |
| 16 | + gato.maulla(); |
| 17 | + |
| 18 | + System.out.println(gato.getNombre() + " - " + gato.getRaza() + " - " + gato.maulla()); |
| 19 | + |
| 20 | + System.out.println("\n"); |
| 21 | + |
| 22 | + // Instancio la clase Gerente |
| 23 | + // Gerente gerente = new Gerente(null, null, null); |
| 24 | + ArrayList<Gerente> gerentes = new ArrayList<>(); |
| 25 | + gerentes.add(new Gerente(1L, "Andres", "Desarrollo")); |
| 26 | + gerentes.add(new Gerente(2L, "Laura", "Diseño Gráfico")); |
| 27 | + gerentes.add(new Gerente(3L, "Luis", "Contabilidad")); |
| 28 | + Gerente.listarGerentes(gerentes); |
| 29 | + |
| 30 | + ArrayList<GerenteDeProyecto> gerentePro = new ArrayList<>(); |
| 31 | + gerentePro.add(new GerenteDeProyecto(1L, "Diego", "Curso Java Web")); |
| 32 | + gerentePro.add(new GerenteDeProyecto(2L, "Ana", "Diseño de interfeces de usuario")); |
| 33 | + gerentePro.add(new GerenteDeProyecto(3L, "Sara", "Automatización Nómina")); |
| 34 | + GerenteDeProyecto.listarGerentesProyecto(gerentePro); |
| 35 | + |
| 36 | + ArrayList<Programador> programadorer = new ArrayList<>(); |
| 37 | + programadorer.add(new Programador(1L, "Julio Cesar", "Roma")); |
| 38 | + programadorer.add(new Programador(2L, "Alejandro","Grecia")); |
| 39 | + programadorer.add(new Programador(3L, "Willian", "Escocia")); |
| 40 | + Programador.listarProgramadores(programadorer); |
| 41 | + } |
| 42 | +} |
| 43 | + |
| 44 | +//Se crea la superclase Animal |
| 45 | +class Animal { |
| 46 | + private String nombre; |
| 47 | + private String raza; |
| 48 | + |
| 49 | + public Animal(String nombre, String raza) { |
| 50 | + super(); |
| 51 | + this.nombre = nombre; |
| 52 | + this.raza = raza; |
| 53 | + } |
| 54 | + |
| 55 | + public String getNombre() { |
| 56 | + return nombre; |
| 57 | + } |
| 58 | + |
| 59 | + public void setNombre(String nombre) { |
| 60 | + this.nombre = nombre; |
| 61 | + } |
| 62 | + |
| 63 | + public String getRaza() { |
| 64 | + return raza; |
| 65 | + } |
| 66 | + |
| 67 | + public void setRaza(String raza) { |
| 68 | + this.raza = raza; |
| 69 | + } |
| 70 | +} |
| 71 | + |
| 72 | +//Se crea la clase perro que hereda de la Clase Animal |
| 73 | +class Perro extends Animal { |
| 74 | + |
| 75 | + public Perro(String nombre, String raza) { |
| 76 | + super(nombre, raza); |
| 77 | + } |
| 78 | + |
| 79 | + public String ladra() { |
| 80 | + return "guau, guau"; |
| 81 | + } |
| 82 | +} |
| 83 | + |
| 84 | +//Se crea la clase Gato que hereda de la Clase Animal |
| 85 | +class Gato extends Animal { |
| 86 | + public Gato(String nombre, String raza) { |
| 87 | + super(nombre, raza); |
| 88 | + } |
| 89 | + |
| 90 | + public String maulla() { |
| 91 | + return "miau, miau"; |
| 92 | + } |
| 93 | +} |
| 94 | + |
| 95 | +//DIFICULTAD EXTRA |
| 96 | + |
| 97 | +class Empleado { |
| 98 | + private Long idEmpleado; |
| 99 | + private String nombre; |
| 100 | + |
| 101 | + public Empleado(Long idEmpleado, String nombre) { |
| 102 | + super(); |
| 103 | + this.idEmpleado = idEmpleado; |
| 104 | + this.nombre = nombre; |
| 105 | + } |
| 106 | + |
| 107 | + public Long getIdEmpleado() { |
| 108 | + return idEmpleado; |
| 109 | + } |
| 110 | + |
| 111 | + public void setIdEmpleado(Long idEmpleado) { |
| 112 | + this.idEmpleado = idEmpleado; |
| 113 | + } |
| 114 | + |
| 115 | + public String getNombre() { |
| 116 | + return nombre; |
| 117 | + } |
| 118 | + |
| 119 | + public void setNombre(String nombre) { |
| 120 | + this.nombre = nombre; |
| 121 | + } |
| 122 | +} |
| 123 | + |
| 124 | +class Gerente extends Empleado { |
| 125 | + String area; |
| 126 | + |
| 127 | + public Gerente(Long idEmpleado, String nombre, String area) { |
| 128 | + super(idEmpleado, nombre); |
| 129 | + this.area = area; |
| 130 | + } |
| 131 | + |
| 132 | + public String getArea() { |
| 133 | + return area; |
| 134 | + } |
| 135 | + |
| 136 | + public void setArea(String area) { |
| 137 | + this.area = area; |
| 138 | + } |
| 139 | + |
| 140 | + public static void listarGerentes(ArrayList<Gerente> gerentes) { |
| 141 | + System.out.println("\nLISTA DE GERENTES DE LA EMPRESA"); |
| 142 | + for (int i = 0; i < gerentes.size(); i++) { |
| 143 | + System.out.println("Área: " + gerentes.get(i).getArea() + " | Gerente: " + gerentes.get(i).getNombre()); |
| 144 | + } |
| 145 | + } |
| 146 | + |
| 147 | + public static void contratarEmpleados() { |
| 148 | + System.out.println("Vas a contratar un nuevo empleado"); |
| 149 | + } |
| 150 | + |
| 151 | + public static void nuevoProyecto() { |
| 152 | + System.out.println("Creando nuevo proyecto"); |
| 153 | + } |
| 154 | +} |
| 155 | + |
| 156 | +class GerenteDeProyecto extends Empleado { |
| 157 | + String proyecto; |
| 158 | + |
| 159 | + public GerenteDeProyecto(Long idEmpleado, String nombre, String proyecto) { |
| 160 | + super(idEmpleado, nombre); |
| 161 | + this.proyecto = proyecto; |
| 162 | + } |
| 163 | + |
| 164 | + public String getProyecto() { |
| 165 | + return proyecto; |
| 166 | + } |
| 167 | + |
| 168 | + public void setProyecto(String proyecto) { |
| 169 | + this.proyecto = proyecto; |
| 170 | + } |
| 171 | + |
| 172 | + public static void listarGerentesProyecto(ArrayList<GerenteDeProyecto> gerentePro) { |
| 173 | + System.out.println("\nLISTA DE GERENTES DE PROYECTOS"); |
| 174 | + for (int i = 0; i < gerentePro.size(); i++) { |
| 175 | + System.out.println( |
| 176 | + "Proyecto: " + gerentePro.get(i).getProyecto() + " | Gerente: " + gerentePro.get(i).getNombre()); |
| 177 | + } |
| 178 | + } |
| 179 | + |
| 180 | + public static void asignarDesarrollador() { |
| 181 | + System.out.println("Asignando nuevo desarrollador al equipo y proyecto"); |
| 182 | + } |
| 183 | +} |
| 184 | + |
| 185 | +class Programador extends Empleado { |
| 186 | + String equipoDeTrabajo; |
| 187 | + |
| 188 | + public Programador(Long idEmpleado, String nombre, String equipoDeTrabajo) { |
| 189 | + super(idEmpleado, nombre); |
| 190 | + this.equipoDeTrabajo = equipoDeTrabajo; |
| 191 | + } |
| 192 | + |
| 193 | + public String getEquipoDeTrabajo() { |
| 194 | + return equipoDeTrabajo; |
| 195 | + } |
| 196 | + |
| 197 | + public void setEquipoDeTrabajo(String equipoDeTrabajo) { |
| 198 | + this.equipoDeTrabajo = equipoDeTrabajo; |
| 199 | + } |
| 200 | + |
| 201 | + public static void listarProgramadores(ArrayList<Programador> programadores) { |
| 202 | + System.out.println("\nLISTA DE PROGRAMADORES"); |
| 203 | + for (int i = 0; i < programadores.size(); i++) { |
| 204 | + System.out.println("Equipo de trabajo: " + programadores.get(i).getEquipoDeTrabajo() + " | Programador: " |
| 205 | + + programadores.get(i).getNombre()); |
| 206 | + } |
| 207 | + } |
| 208 | + |
| 209 | + public static void desarrollarAplicacion() { |
| 210 | + System.out.println("Iniciando el desarrollo de la app para el equipo"); |
| 211 | + } |
| 212 | +} |
0 commit comments