0
I’m having a question in this exercise about Collections in which I should use the Queue interface :
- Write a program that simulates control of an airfield at an airport. In this program, the user must be able to perform the following tasks:
a) List the number of aircraft waiting in the takeoff queue;
b) Allow take-off of the first aeroplane in line;
c) Add an airplane to the queue;
d) List all aircraft in the queue;
e) List the characteristics of the first plane in line.
Consider that airplanes have a name and an integer number as identifier. Add other features as you see fit.
I started my code so 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());
}
}
I didn’t understand the difference between the takeoff line and the waiting line
– Sorack