Download - 3 Herencia
![Page 1: 3 Herencia](https://reader031.vdocuments.pub/reader031/viewer/2022020201/568cab211a28ab186da4515f/html5/thumbnails/1.jpg)
HERENCIAJAVA
3
![Page 2: 3 Herencia](https://reader031.vdocuments.pub/reader031/viewer/2022020201/568cab211a28ab186da4515f/html5/thumbnails/2.jpg)
CONCEPTO
Es posible hacer uso de una clase ya existente, clonarla, y después hacer al "clon" las adiciones y modificaciones que sean necesarias, esto se logra mediante la herencia, con la excepción de que si se cambia la clase original (denominada la clase base, superclase o clase padre), el "clon" modificado (denominado clase derivada, subclase o clase hijo) también reflejaría esos cambios.
![Page 3: 3 Herencia](https://reader031.vdocuments.pub/reader031/viewer/2022020201/568cab211a28ab186da4515f/html5/thumbnails/3.jpg)
EJEMPLO
En un hospital, de los pacientes atendidos se almacena la siguiente información:
Paciente Interno: CURP, nombre, padecimiento, tratamiento, área, sala, cama
Paciente Externo: CURP, nombre, padecimiento, tratamiento, medico tratante, consultorio, fecha y hora
![Page 4: 3 Herencia](https://reader031.vdocuments.pub/reader031/viewer/2022020201/568cab211a28ab186da4515f/html5/thumbnails/4.jpg)
SIN HERENCIA
PacienteInterno
-cURP : String-nombre : String -padecimiento : String -tratamiento : String-area : String -sala : byte-cama : byte
+get...+set...
PacienteExterno
-cURP : String-nombre : String -padecimiento : String -tratamiento : String -medicoTratante : String-consultorio : byte-fecha : String-hora : String
+get...+set...
![Page 5: 3 Herencia](https://reader031.vdocuments.pub/reader031/viewer/2022020201/568cab211a28ab186da4515f/html5/thumbnails/5.jpg)
ANÁLISIS
PacienteInterno
-cURP : String-nombre : String -padecimiento : String -tratamiento : String-area : String -sala : byte-cama : byte
+get...+set...
PacienteExterno
-cURP : String-nombre : String -padecimiento : String -tratamiento : String -medicoTratante : String-consultorio : byte-fecha : String-hora : String
+get...+set...14 métodos 16 métodos
![Page 6: 3 Herencia](https://reader031.vdocuments.pub/reader031/viewer/2022020201/568cab211a28ab186da4515f/html5/thumbnails/6.jpg)
CON HERENCIAPaciente
-cURP : String-nombre : String -padecimiento : String -tratamiento : String
+get...+set...
PacienteInterno
-area : String -sala : byte-cama : byte
+get...+set...
PacienteExterno
-medicoTratante : String-consultorio : byte-fecha : String-hora : String
+get...+set...
extends extends
![Page 7: 3 Herencia](https://reader031.vdocuments.pub/reader031/viewer/2022020201/568cab211a28ab186da4515f/html5/thumbnails/7.jpg)
ANÁLISISPaciente
-cURP : String-nombre : String -padecimiento : String -tratamiento : String
+get...+set...
PacienteInterno
-area : String -sala : byte-cama : byte
+get...+set...
PacienteExterno
-medicoTratante : String-consultorio : byte-fecha : String-hora : String
+get...+set...
extends extends
8 métodos
6 métodos 8 métodos
![Page 8: 3 Herencia](https://reader031.vdocuments.pub/reader031/viewer/2022020201/568cab211a28ab186da4515f/html5/thumbnails/8.jpg)
CODIFICACIÓN
![Page 9: 3 Herencia](https://reader031.vdocuments.pub/reader031/viewer/2022020201/568cab211a28ab186da4515f/html5/thumbnails/9.jpg)
![Page 10: 3 Herencia](https://reader031.vdocuments.pub/reader031/viewer/2022020201/568cab211a28ab186da4515f/html5/thumbnails/10.jpg)
APLICACIÓN
![Page 11: 3 Herencia](https://reader031.vdocuments.pub/reader031/viewer/2022020201/568cab211a28ab186da4515f/html5/thumbnails/11.jpg)