Attribute of an abstract class from another class within the same package

0

Good morning.

I have a problem with that: they send me to make a package with several classes, the first class is "client" (with attributes idCliente and name), the second is "Account". The class "Account", is abstract where one of its attributes is "owner" and it asks me that this attribute be of the type "Client", since it is associated with the name. It does not say that they have any kind of inheritance, but they are in the same package.

I'm starting, I hope you can help me.

    
asked by MeN 17.01.2018 в 22:14
source

1 answer

0

Well, thanks for the Jorgesys tutorial. I've read it and that pretty much I know. We go by parties; I make the class "Client", with private visibility and with the attributes and methods that it asks:

public class Cliente {
    
    private int idCliente;
    private String nombre;
    private String direccion;
    private String telefono;
    
    public Cliente (){
        
    }
    
    public Cliente (int idCliente, String nombre, String direccion, String telefono){
        
        this.idCliente = idCliente;
        this.nombre = nombre;
        this.direccion = direccion;
        this.telefono = telefono;
        
    }
    
    public int getIdCliente(){
        return idCliente;
    }
    
    public void setIdCliente(int idCliente){
        this.idCliente = idCliente;
    }
    
    public String getNombre(){
        return nombre;
    }
    
    public void setNombre(String nombre){
        this.nombre = nombre;
    }
    
    public String getDireccion(){
        return direccion;
    }
    
    public void setDireccion(String direccion){
        this.direccion = direccion;
    }
    
    public String getTelefono(){
        return telefono;
    }
    
    public void setTelefono(String telefono){
        this.telefono = telefono;
    }

I do the class "Account", which asks that it be abstract, protected visibility and with these attributes and methods:

public abstract class Cuenta {
    
    protected int numeroDeCuenta;
    protected double saldo;
    protected xxxxx titular;
    
}

And there I am stuck, in those "xxxxx". Ask that the "owner" attribute be of the "Client" type, that is, of the client class. Any clue how to implement it from that class to the abstract?

    
answered by 17.01.2018 в 23:55