I have two arrayList in a class, one which stores cars and another who stores vans.
I want to have an option to display all the info from a specific array. For example, press 1 for cars or press 2 for vans.
I managed to make something but it's not working properly, after I choose 2, it shows me all the vans but instead of proceeding with next line it and ask which model to rent, it asks again to " press 1 for cars, press 2 for vans".
Here is the code, I hope u understand my question
List<Van> vanlist = new ArrayList();
vanlist.add(new Van("Mercedes", "Van2", "VBC842", 300, 500));
vanlist.add(new Van("Mercedes", "Van3", "VBC489", 300, 500));
vanlist.add(new Van("Mercedes", "Van1", "VBC970", 300, 500));
vanlist.add(new Van("Mercedes", "Van4", "VBC153", 300, 500));
Scanner input = new Scanner(System.in);
System.out.print("Type 1 for cars; Type 2 for vans; Type 3 for trucks \n");
int vop = input.nextInt();
for(Van van: vanlist) {
if (vop == 2) {
System.out.println(van);
}
}
System.out.print("Type 1 for cars; Type 2 for vans; Type 3 for trucks \n");
int opt = input.nextInt();
for(Car car: carlist) {
if (opt == 1) {
System.out.println(car);
}
}
System.out.print("Enter model to rent: ");
String model = input.nextLine();