0
I have to develop a program in Java that will rent a library.
In one part of the program I have to make a ArrayList
of publications, follows the question:
We must create a system for controlling libraries and their loans. A library has a name, an address and stores a set of publications. Currently, the available publications are articles, books and theses. All publications have date of publication, a title, a list of other publications to which they refer and the set of authors of the publication. Attributes relevant to an author are their name and title. Relevant attributes for articles are their title, their date of publication, their authors, the others publications he refers to and his summary. For books it is relevant to store their title, their date of publication, the other publications that he references, their authors, the issue number, the name of the publisher and their ISBN. For the theses it is relevant to store its title, its date of publication, the other publications it references, the author of the thesis, the number of pages, abstract, date of the defense and the institution in which the thesis was defended.
When I create the class Biblioteca
, and put the ArrayList
of the publications in the constructor, how the implementation of this ArrayList
? Do I have to do a method within the class to fill it in? It follows code from the class I did.
import java.util.ArrayList;
public class Biblioteca {
private String nome;
private String endereco;
private ArrayList<Publicacoes> publicacoes;
public Biblioteca(String nome, String endereco, ArrayList<Publicacoes> publicacoes) {
super();
this.nome = nome;
this.endereco = endereco;
this.publicacoes = publicacoes;
}
String getNome() {
return nome;
}
void setNome(String nome) {
this.nome = nome;
}
String getEndereco() {
return endereco;
}
void setEndereco(String endereco) {
this.endereco = endereco;
}
ArrayList<Publicacoes> getPublicacoes() {
return publicacoes;
}
void setPublicacoes(ArrayList<Publicacoes> publicacoes) {
this.publicacoes = publicacoes;
}
}
Possible duplicate of How I create an Arraylist of objects with each position containing a new object?
– user148754
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site
– Maniero