OneCompiler

Java

117
 package model;
import java.util.ArrayList;
import java.util.Scanner;

public class PickupScheduling {
    public static void updatePickupDropSchedule(ArrayList<String[]> bookings) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter Booking ID to update Pickup/Drop schedule: ");
        String inputId = sc.nextLine();
        boolean found = false;

        for (String[] booking : bookings) {
            if (booking[15].equals(inputId)) { // Check if booking ID matches
                System.out.println("\n--- Booking Details ---");
                System.out.println("Booking ID           : " + booking[15]);
                System.out.println("Sender Name          : " + booking[1]);  
                System.out.println("Sender Address       : " + booking[2]);  
                System.out.println("Receiver Name        : " + booking[3]);
                System.out.println("Receiver Address     : " + booking[4]);
                System.out.println("Date of Booking      : " + booking[14]); 
                System.out.println("Parcel Status        : In Transit");
                System.out.println("Current Pickup Time  : " + booking[11]);
                System.out.println("Current Drop-off Time: " + booking[12]);

                System.out.print("\nEnter new Pickup Time: ");
                booking[11] = sc.nextLine();

                System.out.print("Enter new Drop-off Time: ");
                booking[12] = sc.nextLine();

                System.out.println("Pickup and Drop-off times updated successfully.");
                found = true;
                break;
            }
        }

        if (!found) {
            System.out.println("Booking ID not found.");
        }
    }
}