Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class Test
- {
- /**
- A driver that demonstrates the class SortedLinkedList with Student.
- @author CSIT265
- */
- public static void main(String[] args) throws FileNotFoundException
- {
- Scanner inFile = new Scanner(new FileReader("/Users/Eric/Documents/Flights.txt"));
- SortedListInterface<TakeOff> myList = new SortedLinkedList<TakeOff>(7);
- String key;
- String key2;
- String numberofflight;
- String dateofflight;
- String timeofflight;
- String place;
- while (inFile.hasNextLine())
- {
- String line = inFile.nextLine();
- String[]lineArray = line.split(" ");
- numberofflight = lineArray[1];
- key = numberofflight;
- dateofflight = lineArray[2];
- timeofflight = lineArray[3];
- TakeOff takeoff = new TakeOff(numberofflight, dateofflight, timeofflight);
- place = lineArray[0];
- key2 = place;
- TakeOff takeoff2 = new TakeOff(place, numberofflight, dateofflight, timeofflight);
- myList.add(takeoff, key);
- myList.add(takeoff2, key2);
- }
- inFile.close();
- displayList(myList);
- TakeOff[] myArray = myList.getObjectsForKey("108 03/06/12");
- for(int a = 0; a < myArray.length; ++a)
- {
- System.out.println(myArray[a].getflightnumber() + " " + myArray[a].getflightdate() + " ");
- }
- // test methods
- Student oneStudent = new Student();
- oneStudent.setStudent("Sophomore", "Baker, Charles", 12, 0, 0.0f);
- System.out.println(oneStudent);
- System.out.println("Contains "+ myList.contains(oneStudent, "Sophomore"));
- int loc = myList.getPosition(oneStudent, "Sophomore");
- System.out.println ("Get Position " + loc);
- System.out.println("Get Entry " + myList.getEntry(loc, 4));
- System.out.println("Remove " + myList.remove(oneStudent, "Sophomore"));
- oneStudent.setStudent("Freshman", "Lang, Kris", 12, 0, 0.0f);
- System.out.println("Remove " + myList.remove(oneStudent, "Freshman"));
- System.out.println("Remove " + myList.remove(1, 4));
- System.out.println("Get Entry " + myList.getEntry(1, 4));
- System.out.println("new length " + myList.getLength(4));
- System.out.println("Remove " + myList.remove(7,4));
- System.out.println("Remove " + myList.remove(3,4));
- displayList(myList);
- } // end main
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement