Assessment Task
Your task is to develop a Java Application that allows the user to read travel booking data from a text file (inBooking.txt), save data in a file (outBooking.txt), display data in a text area, sort data by booking name and search data by booking name.
The application GUI components should consist of a menu bar containing 3 menus (File, Sort Data, Search Data) and a text area (Display Area) as shown below.
There are three menus (File, Sort Data, Search Data). The File menu contains 4 items (Open, Show Data, Save Data, Exit), Sort Data menu contains 2 items (Bubble Sort and Merge Sort), Search Data menu contains 2 items (Linear Search and Binary Search). The menu items are described below.
File→Open: Open and read data from inBooking.txt (see format of this file below) and store data in a Linked List or an ArrayList.
The file contains Booking Id (String), Booking Name (String), Flight (double), Accommodation (double), Meal (double) and Total Expenses (double). A sample file format for inBooking.txt is as follows.
1345, Mike Douglas, 102, 120, 100, 322
1879, John Bobber, 200, 180, 120, 500
2560, Andrew Beck, 150, 300, 150, 600
3212, Rick Water, 200, 100, 140, 440
File→Show Data: Read data from ArrayList/Linked List and show in a display area as shown below.
File→Save Data: Read data from ArrayList/LinkedList and save data in outBooking.txt file. The format is same as format in inBooking.txt file.
File→ Exit: Allows user to exit the application.
Sort Data→Bubble Sort: Sort ArrayList/LinkedList by name in ascending order using Bubble Sort algorithm and display sorted data in display area as shown below.
Sort Data→Merge Sort: Sort ArrayList/LinkedList by name in ascending order using Merge Sort algorithm and display sorted data in display area as shown below.
Search Data→Linear Search: Ask the user to enter a name via a dialog box as shown below and use a linear search algorithm to search for the name. It should display an appropriate message found or not found in display area.
Search Data→Binary Search: Ask the user to enter a name via a dialog box as shown below and use a binary search algorithm to search for the name. It should display an appropriate message found or not found in display area.
Data Validation
Input data validation for name entered to search is required. If no name entered or entered name is longer than 15 characters and OK button is pressed then the application will pop out a message box with an appropriate message.
Data Structures & Algorithms
You must use:
• LinkedList or ArrayList for storing and processing data.
• linear and binary search algorithms for searching.
• bubble sort and merge sort algorithms for sorting.
• two classes to implement the application. One class, named Booking which describes an individual booking and the other class named ProcessBookingApplication which contains GUI with components and methods for sorting, searching and file processing.
• appropriate fields to store booking id, name, flight, accommodation, meal and total booking cost.