/* * File: AirDataListTest.java * * A test class for the AirData and AirDataList classes * * Purpose: to give students experience in reading data from a * file until eof and extrcting the individual "tokens" from * each line (or "record") of the file */ /*********************************************************************** * You will add statements in the indicated places to * 1. Create a Scanner object associated with the current line of input * 2. Call Scanner methods to extract the tokens from the line * 3. Create an AirData object using the tokens * 4. Add the object to the list ****************************************************************************/ import java.io.File; import java.io.IOException; import java.util.Scanner; public class AirDataListTest { public static void main(String[] args) throws IOException { AirDataList list = new AirDataList(); // create Scanner object associated with the input file Scanner infile = new Scanner(new File("AirData.txt")); System.out.println("Data entered:\n"); while (infile.hasNext()) // while not eof... { // read next line of the file (done) String line = infile.nextLine(); // "echo print" the line read (done) System.out.println(line); // TO DO: // 1. create a Scanner object associated with String "line" // 2. extract the 3 tokens from the current line // 3. create an AirData object passing the tokens to the constructor // 4. call the method to add the new AirData object to the // AirDataList object, list } System.out.println(); System.out.println(list.toString()); // print the list } } // end of AirDataListTester class definition