Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.36 KB | None | 0 0
  1.  
  2.  
  3. import java.io.*;
  4. import java.util.*;
  5.  
  6. public class Test
  7. {
  8.    
  9.     /**
  10.        A driver that demonstrates the class SortedLinkedList with Student.
  11.        
  12.        @author CSIT265
  13.      
  14.     */
  15.        
  16.         public static void main(String[] args) throws FileNotFoundException
  17.         {
  18.             Scanner inFile = new Scanner(new FileReader("/Users/Eric/Documents/Flights.txt"));
  19.             SortedListInterface<TakeOff> myList = new SortedLinkedList<TakeOff>(7);
  20.             String key;
  21.             String key2;
  22.             String numberofflight;
  23.             String dateofflight;
  24.             String timeofflight;
  25.             String place;
  26.    
  27.             while (inFile.hasNextLine())
  28.             {
  29.                
  30.        
  31.                 String line = inFile.nextLine();
  32.                 String[]lineArray = line.split(" ");
  33.                 numberofflight = lineArray[1];
  34.                 key = numberofflight;
  35.                 dateofflight = lineArray[2];
  36.                 timeofflight = lineArray[3];
  37.                 TakeOff takeoff = new TakeOff(numberofflight, dateofflight, timeofflight);
  38.                 place = lineArray[0];
  39.                 key2 = place;
  40.                 TakeOff takeoff2 = new TakeOff(place, numberofflight, dateofflight, timeofflight);
  41.                
  42.                
  43.                 myList.add(takeoff, key);
  44.                 myList.add(takeoff2, key2);
  45.             }
  46.             inFile.close();
  47.             displayList(myList);
  48.                
  49.                 TakeOff[] myArray = myList.getObjectsForKey("108 03/06/12");
  50.                 for(int a = 0; a < myArray.length; ++a)
  51.                 {
  52.                     System.out.println(myArray[a].getflightnumber() + " " + myArray[a].getflightdate() + " ");
  53.                 }
  54.    
  55.            
  56.            
  57.     // test methods
  58.             Student oneStudent = new Student();
  59.            
  60.             oneStudent.setStudent("Sophomore", "Baker, Charles", 12, 0, 0.0f);
  61.             System.out.println(oneStudent);
  62.            
  63.             System.out.println("Contains "+ myList.contains(oneStudent, "Sophomore"));
  64.             int loc = myList.getPosition(oneStudent, "Sophomore");
  65.             System.out.println ("Get Position " + loc);
  66.            
  67.             System.out.println("Get Entry " + myList.getEntry(loc, 4));
  68.             System.out.println("Remove " + myList.remove(oneStudent, "Sophomore"));
  69.             oneStudent.setStudent("Freshman", "Lang, Kris", 12, 0, 0.0f);
  70.             System.out.println("Remove " + myList.remove(oneStudent, "Freshman"));
  71.            
  72.             System.out.println("Remove " + myList.remove(1, 4));
  73.             System.out.println("Get Entry " + myList.getEntry(1, 4));
  74.             System.out.println("new length " + myList.getLength(4));
  75.            
  76.             System.out.println("Remove " + myList.remove(7,4));
  77.             System.out.println("Remove " + myList.remove(3,4));
  78.             displayList(myList);
  79.         }  // end main
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement