1
I’m having a question of how to proceed, there are syntax errors as you can see. But my knowledge is basic and I’m trying to improve. I have the following program. A register of Flights, only with number, origin, destination and number of vacancies.
I created a Class
package aeroporto;
public class aviao {
aviao[] voo = new voo[i];
int numero;
String origem;
String destino;
int vagas;
for(int i=0; i<5; i++)
void Cadastrar(int numero,String origem,String destino, int vagas)
{
voo[i].numero = numero;
voo[i].origem = origem;
voo[i].destino = destino;
voo[i].vagas = vagas;
}
}
and the main program is this
package aeroporto;
import java.util.Scanner;
public class Aeroporto {
public static void main(String[] args) {
Scanner teclado = new Scanner(System.in);
int numero,vagas,i=0;
String origem,destino;
int op;
do{
System.out.println("****Menu Aeroporto****");
System.out.println("1. Cadastro de vôo");
System.out.println("2. Consultar vôo");
System.out.println("3. Reservar Passagem");
System.out.println("5. Sair");
//ler entrada
op =teclado.nextInt();
if(op==4)
{
System.exit(1);
}
switch(op){
case 1:
for(i=0 ; i<5 ; i++){
System.out.print ("Número do voo: ");
numero =teclado.nextInt();
System.out.print("Origem : ");
origem = teclado.next();
System.out.print("Destino : ");
destino = teclado.next();
System.out.print("Número de vagas : ");
vagas = teclado.nextInt();
aviao.Cadastrar (numero, origem, destino,vagas);
}
break;
}
}while(true);
}
}
I ask you to point out my mistakes and how to proceed. Note: I am trying to make this vector of objects instead of using Arraylist, because I have no idea how it does.
There’s so many mistakes I don’t even know where to start. I’ll tell you something I think is the best I can do for you, but most people who hear this ignore it and keep bumping heads. Start at the beginning, learn one thing at a time, only move on to the next when you understand the current one well. Keep increasing the complexity gradually, let OOP last (this code has nothing OO). Until you know the reason for each character, even the space in your code can’t think of more sophisticated things. I started improving, but he has serious conceptual errors,
– Maniero
so I let it go. There are no more syntax errors, but it’s still very wrong: http://tpcg.io/X9TuHo
– Maniero
@Maniero the way I did, was how I learned in college. But good to know that there are conceptual errors. I will seek to learn more. Thank you.
– J.C. Ferri