Doubts with the OOP

0

I have created two classes, Author and Book.

public class Autor {

private final String nombreAutor;
private final String email;
private final char sexo;
private final  Libro[] libros;
private final Libro[] librosEscritos;


public Autor(String nombreAutor, String email, char sexo, Libro[] libros, Libro[] librosEscritos) {
    this.nombreAutor = nombreAutor;
    this.email = email;
    this.sexo = sexo;
    this.libros = libros;
    this.librosEscritos = librosEscritos;
}



//Metodos get y set
public String getNombre() {
    return nombreAutor;
}

public String getEmail() {
    return email;
}

public char getSexo() {
    return sexo;
}

public Libro[] getLibros() {
    return libros;
}

public Libro[] getLibrosEscritos() {
    return librosEscritos;
}

  public Libro[] setLibrosEscritos() {
    return librosEscritos;
}


public Libro[] setLibros() {
    return libros;
}

public String setNombre() {
    return nombreAutor;
}

public String setEmail() {
    return email;
}

public char setSexo() {
    return sexo;
}

public class Book {

private final String nombreLibro;

private final double precio;
private final int cantidadEnStock;
private final Autor[] autores;
private final String librosEscritos;

public Libro(String nombreLibro, double precio, int cantidadEnStock, Autor[] autores, String librosEscritos) {
    this.nombreLibro = nombreLibro;
    this.precio = precio;
    this.cantidadEnStock = cantidadEnStock;
    this.autores = autores;
    this.librosEscritos=librosEscritos;
}

//Metodos get y set
public String getNombre() {
    return nombreLibro;
}

public double getPrecio() {
    return precio;
}

public int getCantidadEnStock() {
    return cantidadEnStock;
}

public Autor[] getAutores() {
    return autores;
}

public String getLibrosEscritos() {
    return librosEscritos;
}

   public String setLibrosEscritos() {
    return librosEscritos;
}

public Autor[] setAutores() {
    return autores;
}

public String setNombre() {
    return nombreLibro;
}

public double setPrecio() {
    return precio;
}

public int setCantidadEnStock() {
    return cantidadEnStock;
}

But I do not understand how to do it "adds a new attribute in the Author class that will be" Written: List (Book) "Would it be well done as I put it? I do not understand what to do " books Written: List (Book) ". Thanks

    
asked by kitkat 22.01.2017 в 10:58
source

1 answer

0

'Written books: List (Book) is simply telling you that the attribute has to be called' Written books' and that it must be of the List type (Book). The change I would make about yours is that you have created a vector of type 'Book', I would create a list of type 'Book' that is what they ask you.

private final List<Libro> librosEscritos;

docs.oracle.com/javase/7/docs/api/java/util/List.html

    
answered by 22.01.2017 в 14:16