0
I am implementing an exercise requested in class regarding the insertion of objects in a Linkedlist (queue), but I do not know how to print the information of the objects on the screen.
Follow the developed classes:
package classes;
public class Animal {
private int id_animal;
private int idade;
private String raca;
public int getId_animal() {
return id_animal;
}
public void setId_animal(int id_animal) {
this.id_animal = id_animal;
}
public int getIdade() {
return idade;
}
public void setIdade(int idade) {
this.idade = idade;
}
public String getRaca() {
return raca;
}
public void setRaca(String raca) {
this.raca = raca;
}
}
package classes;
import java.util.LinkedList;
import java.util.List;
public class FilaAnimais {
private List<Animal> animais = new LinkedList<Animal>();
public void insere(Animal animal) {
this.animais.add(animal);
}
public Animal remove() {
return this.animais.remove(0);
}
public boolean vazia() {
return this.animais.size() == 0;
}
}
package classes;
public class TesteFila {
public static void main(String[] arg) {
FilaAnimais filaAnimais = new FilaAnimais
Animal animal = new Animal();
animal.setId_animal(0);
animal.setIdade(2);
animal.setRaca("Pinscher");
filaAnimais.insere(animal);
}
}
I would like to know how to print on the screen the information of the objects I inserted in this queue.