Skip to content

Commit fc662f2

Browse files
Herencia
Hererencia see also: resolves:
1 parent 9fa333f commit fc662f2

File tree

2 files changed

+56
-3
lines changed

2 files changed

+56
-3
lines changed

Herencia/src/domain/Persona.java

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,61 @@
11
package domain;
22

33
public class Persona {
4-
protected String nombre; // tiene acceso las clases hijas
5-
protected char
4+
private String nombre; // tiene acceso las clases hijas
5+
private char genero;
6+
private int edad;
7+
private String direccion;
68

9+
public Persona(){ // Contructor
10+
}
11+
12+
public Persona(String nombre){// Contructor
13+
this.nombre = nombre;
14+
}
15+
16+
public Persona(String nombre, char genero, int edad, String direccion) {
17+
this.nombre = nombre;
18+
this.genero = genero;
19+
this.edad = edad;
20+
this.direccion = direccion;
21+
}
22+
23+
public String getDireccion() {
24+
return this.direccion;
25+
}
26+
27+
public void setDireccion(String direccion) {
28+
this.direccion = direccion;
29+
}
30+
31+
public String getNombre() {
32+
return this.nombre;
33+
}
34+
35+
public void setNombre(String nombre) {
36+
this.nombre = nombre;
37+
}
38+
39+
public char getGenero() {
40+
return this.genero;
41+
}
42+
43+
public void setGenero(char genero) {
44+
this.genero = genero;
45+
}
46+
47+
public int getEdad() {
48+
return this.edad;
49+
}
50+
51+
public void setEdad(int edad) {
52+
this.edad = edad;
53+
}
54+
55+
@Override
56+
public String toString() {
57+
return "Persona{" + "nombre=" + nombre + ", genero=" + genero + ", edad=" + edad + ", direccion=" + direccion + '}';
58+
}
759

860
}
61+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1675,7 +1675,7 @@ palabra `static`
16751675

16761676
| Carpeta | Link | Home | Code | Version | Estado |
16771677
|----------------------------|:-----------:|:-----------:|:-----------:|:-----------:|:-----------:|
1678-
| [Herencia](https://github.com/BrianMarquez3/Learning-Java/tree/main/ContextoStatico_2) | ✔️ | [⬅️Atras](#Fundamentos-Java) | yes | yes | ✔️ |
1678+
| [Herencia](https://github.com/BrianMarquez3/Learning-Java/tree/main/Herencia) | ✔️ | [⬅️Atras](#Fundamentos-Java) | yes | yes | ✔️ |
16791679

16801680
---
16811681
## Spring Boot

0 commit comments

Comments
 (0)