Personal I have a question in this exercise about Collections where I should use the Queue interface:
a) List the number of airplanes waiting in the takeoff queue; Home b) To authorize the takeoff of the first airplane in the queue; Home c) Add an airplane to the queue; Home d) List all the airplanes in the queue; Home e) List the characteristics of the first airplane in the queue.
Consider that airplanes have a name and an integer as an identifier. Add other features as needed.
I started my code like this but I stopped in question "B", I have doubts if it is necessary to use a method
import java.util.ArrayList;
public class ControledeTrafego {
private String nome;
private int codigo;
public ControledeTrafego(String nome, int codigo) {
super();
this.nome = nome;
this.codigo = codigo;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public int getCodigo() {
return codigo;
}
public void setCodigo(int codigo) {
this.codigo = codigo;
}
public void autorizacao(ControledeTrafego autorizacao){
System.out.println("Favor comnfirmar a autorização do voo");
}
}
This is the Program:
package Exercicio3;
import java.util.LinkedList;
import java.util.Queue;
public class Controle {
public static void main(String[] args) {
// TODO Auto-generated method stub
Queue<ControledeTrafego> aviao = new LinkedList<>();
ControledeTrafego aviao1 = new ControledeTrafego(" Tam ", 747);
ControledeTrafego aviao2 = new ControledeTrafego(" Gol ", 737);
ControledeTrafego aviao3 = new ControledeTrafego(" Azul", 722);
aviao.add(aviao1);
aviao.add(aviao2);
aviao.add(aviao3);
System.out.println("Numero de avioes na fila de embarque : " +aviao.size());
}
}