Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.36 KB | None | 0 0
  1. //code is not functional yet, the parsin method still needs to be figured out
  2. //before the methods are fully fleshed-out.
  3.  
  4. import lists.*;
  5. import java.util.LinkedList;
  6. import java.util.Scanner;
  7. import java.io.*;
  8. import java.util.Collections;
  9.  
  10. public class flightlist
  11. {
  12.     public static final int capacity = 10;
  13.    
  14.     public static Scanner FlightFile;
  15.     public static PrintWriter FlightOut;
  16.    
  17.     public static LinkedList<String> Flight598;
  18.     public static LinkedList<String> Flight604;
  19.    
  20.     public static void main(String[] args)
  21.     {
  22.         try
  23.         {
  24.             FlightFile = new Scanner(new File("flight.txt"));
  25.             FlightOut = new PrintWriter( new FileWriter("flightoutput.txt"));
  26.            
  27.             Flight598 = new LinkedList<String>();
  28.             Flight604 = new LinkedList<String>();
  29.            
  30.             String cmd = "";
  31.             String name;
  32.             int flight1, flight2;
  33.            
  34.            
  35.             while (FlightFile.hasNext())
  36.             {
  37.                 cmd = FlightFile.next();
  38.                 System.out.println(cmd);
  39.             }
  40.  
  41.             switch (cmd)
  42.             {
  43.                 case "RESERVE"          : //See reserve
  44.                
  45.                 case "CANCEL"           : //See cancel                                              
  46.                
  47.                 case "FIND"             : //See find
  48.  
  49.                 case "CHANGE"           : //See change
  50.                
  51.                 case "LIST"             : //See list
  52.                
  53.                 case "STOP"             : //See stop
  54.                
  55.                 break;
  56.                 //Defined what each command will do
  57.             }
  58.         }
  59.         catch (IOException e)
  60.         {
  61.             System.out.println("ERROR");
  62.         }
  63.     }
  64.    
  65.     public static void reserve()
  66.     {
  67.         //Implement the flight number? Need to figure out how to parse it
  68.         while(capacity <= 0)
  69.         {
  70.             if(FlightFile.nextInt() = 598)
  71.                 Flight598.add(FlightFile.next());
  72.             else if(FlightFile.nextInt() = 604)
  73.                 Flight604.add(FlightFile.next());
  74.         }
  75.     }
  76.    
  77.     public static void cancel()
  78.     {
  79.         //Check for however the name is parse
  80.         //if (FlightNum contains name)
  81.         if (capacity <10)
  82.         {
  83.             capacity = capacity + 1;
  84.         }
  85.     }
  86.    
  87.     public static void find()
  88.     {
  89.         //for(String s: Flight598)
  90.         // {
  91.         //(if s.contains(name);
  92.         //true
  93.         //else
  94.         //false
  95.        
  96.         //for(String s2: Flight604)
  97.         // {
  98.         //(if s2.contains(name);
  99.         //true
  100.         //else
  101.         //false
  102.     }
  103.    
  104.     public static void change()
  105.     {
  106.         //for name
  107.         //setLink changes to the other list
  108.     }
  109.    
  110.     public static void list()
  111.     {
  112.         Collections.sort(Flight598);
  113.         System.out.println("\n Here are the passengers on Flight 598:");
  114.         System.out.println(Arrays.toString(Flight598.toArray()));
  115.        
  116.         Collections.sort(Flight604);
  117.         System.out.println("\nHere are the passengers on Flight 604:");
  118.         System.out.println(Arrays.toString(Flight604.toArray()));
  119.     }
  120.    
  121.     public static void stop()
  122.     {
  123.         System.out.println("\nOutput is now complete");
  124.     }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement