System.out.println("Which record would you like to delete? \n[1]ID1 [2]ID2 [3]ID3 [4]ID 4");
choice = scan.nextInt();
switch(choice){
case 1:
ArrayList<String> fbRemove = new ArrayList<String>();
fbRemove.removeAll(fb);
ArrayList<Integer> fbVRemove = new ArrayList<Integer>();
fbVRemove.removeAll(fbV);
ArrayList<Integer> fbTotal = new ArrayList<Integer>();
fbTotal.add(sbV.get(3)+ tbV.get(3) + ubV.get(3));
System.out.print(sb);
System.out.println(sbV);
System.out.print(tb);
System.out.println(tbV);
System.out.print(ub);
System.out.print(ubV);
for (int endTotal: fbTotal){
System.out.println("\nSeats remaining:"+ (maxSeats - endTotal));
}
break;
case 2:
ArrayList<String> sbRemove = new ArrayList<String>();
sbRemove.removeAll(sb);
ArrayList<Integer> sbVRemove = new ArrayList<Integer>();
sbVRemove.removeAll(sbV);
ArrayList<Integer> sbTotal = new ArrayList<Integer>();
sbTotal.add(fbV.get(3)+ tbV.get(3) + ubV.get(3));
System.out.print(fb);
System.out.println(fbV);
System.out.print(tb);
System.out.println(tbV);
System.out.print(ub);
System.out.print(ubV);
for (int endTotal: sbTotal){
System.out.println("\nSeats remaining:"+ (maxSeats - endTotal));
}
break;
case 3:
ArrayList<String> tbRemove = new ArrayList<String>();
tbRemove.removeAll(tb);
ArrayList<Integer> tbVRemove = new ArrayList<Integer>();
tbVRemove.removeAll(tbV);
ArrayList<Integer> tbTotal = new ArrayList<Integer>();
tbTotal.add(fbV.get(3)+ sbV.get(3) + ubV.get(3));
System.out.print(fb);
System.out.println(fbV);
System.out.print(sb);
System.out.println(sbV);
System.out.print(ub);
System.out.print(ubV);
for (int endTotal: tbTotal){
System.out.println("\nSeats remaining:"+ (maxSeats - endTotal));
}
break;
case 4:
ArrayList<String> ubRemove = new ArrayList<String>();
ubRemove.removeAll(ub);
ArrayList<Integer> ubVRemove = new ArrayList<Integer>();
ubVRemove.removeAll(ubV);
ArrayList<Integer> ubTotal = new ArrayList<Integer>();
ubTotal.add(fbV.get(3)+ sbV.get(3) + tbV.get(3));
System.out.print(fb);
System.out.println(fbV);
System.out.print(tb);
System.out.println(tbV);
System.out.print(sb);
System.out.print(sbV);
for (int endTotal: ubTotal){
System.out.println("\nSeats remaining:"+ (maxSeats - endTotal));
}
break;
}
System.out.print("\n[1]Add entry [2]Exit");
choice = scan.nextInt();
switch (choice){
case 1:
ArrayList<String> ub2 = new ArrayList<String>();
//Creats an array called SetBooking and gives it 4 identifiers.
String choiceu1;
String choiceu2;
String choiceu3;
System.out.println("Please enter your first name:");
Scanner scan3 = new Scanner(System.in);
choiceu1 = scan3.nextLine();
System.out.println("Please enter your last name:");
choiceu2 = scan3.nextLine();
System.out.println("Please enter your phone number:");
choiceu3 = scan3.nextLine();
ArrayList<Integer> ubV2 = new ArrayList<Integer>();
int adultInput2;
int kidInput2;
System.out.println("Please enter the number of adults:");
adultInput2 = scan3.nextInt();
System.out.println("Please enter the number of children:");
kidInput2 = scan3.nextInt();
ub2.add("5");
ub2.add(choice1);
ub2.add(choice2);
ub2.add(choice3);
ubV2.add(adultInput2);
ubV2.add(kidInput2);
ubV2.add(adultInput2 * AdultPrice + kidInput2 * KidPrice );
ubV2.add(ubV2.get(0) + ubV2.get(1));
ArrayList<Integer> totalMoneyUser2 = new ArrayList<Integer>();
totalMoneyUser2.add(sbV.get(2)+ fbV.get(2) + tbV.get(2) + ubV.get(2));
ArrayList<Integer> totalUser2 = new ArrayList<Integer>();
totalUser2.add(sbV.get(3)+ fbV.get(3) + tbV.get(3) + ubV.get(3) + ubV2.get(3));
if(totalUser2.get(0) <= maxSeats){
System.out.print(ub);
System.out.print(ubV);
System.out.println("\n\nWould you like to see the updated file?");
System.out.println("[1]Yes [2]Menu");
choice = scan.nextInt();
switch(choice){
case 1:
System.out.print(fb);
System.out.println(fbV);
System.out.print(sb);
System.out.println(sbV);
System.out.print(tb);
System.out.println(tbV);
System.out.print(ub);
System.out.println(ubV);
System.out.print(ub2);
System.out.print(ubV2);
for (int moneyUser: totalMoneyUser){
System.out.println("\n\nCoach Revenue: £"+(moneyUser));
}
for (int totalu2: totalUser2){
System.out.println("Seats remaining:"+ (maxSeats - totalu2)+"\n");
System.out.println("Waiting for response");
System.in.read();
}
break;
Essentially my programs gets a user input, adds it into an array, shows all the arrays and the program can be used to delete an input (array value) however when I input a new value it doesn't take away the array which was deleted, can anyone help? Sorry for the messy code. Still trying to get to grips with java.
Aucun commentaire:
Enregistrer un commentaire