1
I have two classes in my project: Cars and Cars.
At first, I have a Linkedlist stated as follows:
private LinkedList<Carro> carros = new LinkedList<Carro>();
Then I have methods of insertion, deletion and listing. However, I also needed to implement a method to receive Car type objects from the class I created to implement the methods referring to cars with the idle situation. This method simply takes an object inserts it at the end of the Linkedlist of my Cars class.
public void alocaCarros(Carro carro) {
this.carros.add(carro);
}
In my class Carrosinativos I have a Linkedlist to store the cars in inactivity:
private LinkedList<Carro> carrosInativos = new LinkedList<Carro>();
To carry out the inclusion of these inactive cars in the list of active cars when needed, I invoked the Cars class within the Carrosinativos class.
Carros carrosAtivos = new Carros();
Within this class, I have the method responsible for passing the objects entered in the inactive car queue to the allocation method:
public void InsereCarros(){
carrosAtivos.alocaCarros(carrosInativos.getFirst());
carrosInativos.remove();
}
Here is the problem: in the tests, both my list of active cars and the list of inactive cars are receiving objects normally; however, when invoking the method, the insertion of the object passed is not performed.
NOTE: When inserting a System.out.println in the class allocateCarros using the received object as parameter, the object is listed normally in the output.