Managing Dynamic Flight Data using Collections

Business Scenario

In the previous lab, we implemented Abstraction, Interfaces, and the DAO pattern to calculate fares and manage flight records using arrays.

Welcome back,Developers!

Pre-Lab Preparation

  • Collection interface and its methods

  • List creation and manipulation

git pull origin branchName

Git Pull

Task 1: Store the Flight data and display it

1

declare the Flight class

2

define the FlightData class. This class has the ArrayList of Flight objects.

Based on user’s choice, required task will be executed using switch-case.

3

4

add the code to accept the Flight information and store it

add the code for exiting the application and handling the invalid choice

5

6

run the code to check the output

Task 2: Searching for existing flight information

1

flight can be searched based on the source and destination

2

run the code

Enter atleast 2 flight details, by choosing first option (add flight)

a

Display all flights, by choosing option 3

b

Select option 2 to search the flight

b

 

Great job!

We learned to use ArrayList to dynamically store and manage flight data by performing add, search, update, delete, and display operations efficiently.

Checkpoint

Java_Lab_16

By Content ITV

Java_Lab_16

  • 6