Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Persona extends Familia{
- // Atributos
- protected String nombre;
- protected int edad;
- protected String dni;
- protected String sexo;
- protected float peso;
- protected float altura;
- // Constructor (vacío)
- public Persona() {
- this.nombre= "";
- this.edad= 0;
- this.dni= "";
- this.sexo= "";
- this.peso= 0f;
- this.altura= 0f;
- }
- // Contructor sobrecargado
- public Persona(int numLibFam, String direccion, String poblacion, String provincia, String nombre, int edad, String dni, String sexo, float peso, float altura) {
- super(numLibFam, direccion, poblacion, provincia); // Carga de los atributos de la superclase (Familia)
- this.nombre= nombre;
- this.edad= edad;
- this.dni= dni;
- this.sexo= sexo;
- this.peso= peso;
- this.altura= altura;
- }
- // Getters & Setters
- public String getNombre() { return nombre; }
- public void setNombre(String nombre) { this.nombre = nombre; }
- public int getEdad() { return edad; }
- public void setEdad(int edad) { this.edad = edad; }
- public String getDni() { return dni; }
- public void setDni(String dni) { this.dni = dni; }
- public String getSexo() { return sexo; }
- public void setSexo(String sexo) { this.sexo = sexo; }
- public float getPeso() { return peso; }
- public void setPeso(float peso) { this.peso = peso; }
- public float getAltura() { return altura; }
- public void setAltura(float altura) { this.altura = altura; }
- // Método info
- public String info() {
- return this.nombre +" - "+ this.edad +" - "+ this.dni +" - "+ this.sexo +" - "+ this.peso +" - "+ this.altura +" / "+ infoFamilia();
- }
- // Implementación del método abstracto IMC
- @Override
- public float imc(){
- float imc = this.peso/(this.altura*this.altura);
- return imc;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement