- Spend some time working on your project.
Now that we have learned a little more about file IO in Java, it's time to apply this new knowledge to our projects!
Provide an option for command-line arguments to insert a list of airports from a file. Consider the following instructions:
- Modify the
AirportReservationDriver
class.- Write a conditional that looks to see if a file was passed in via the command-line.
- If a file exists, read the file in.
- Create a new method in the driver class to read in a file.
- The file can be formatted however you want to format it. It is suggested
you use either a CSV or a JSON format though, so you can easily map it
back to the
Airport
class. - The list of airports should consist of the following fields:
- Airport code.
- Airport name.
- Airport location.
- Set of cities.
- Example:
- Airport Code: DEN
- Airport Name: Denver International Airport.
- Location: Denver, Colorado.
- Some of the cities with services from the Denver International
Airport:
- Durango, Colorado.
- Baltimore, Maryland.
- Portland, Oregon.
- Louisville, Kentucky.
- Paris, France.
- The new method that reads in the file should return a list of airports.
- Don't forget to validate the airport code is in the proper format of three uppercase letters.
- If the file does not exist or is not passed in via the command-line, proceed as normal.
- Write the unit tests to test the reading in of a file.
- Tips:
- Refer back to the labs in this past section as needed.
- Refer back to the unit testing section to help you write the unit tests.
- Refer to the Java documentation as needed. Below are some resources that may help you.