Doragonroudo

Ex.3 ของไข่มุก

Sep 24th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package statistics;
  7.  
  8. import java.io.File;
  9. import java.io.FileNotFoundException;
  10. import java.util.ArrayList;
  11. import java.util.Comparator;
  12. import java.util.Scanner;
  13.  
  14. /**
  15.  *
  16.  * @author 6272user
  17.  */
  18. class Airline implements Comparable<Airline> {
  19.    private String name;
  20.    private int    founded, aircrafts, destinations;
  21.    public void report()                 { /* print result */ }
  22.  
  23.    @Override
  24.    public int compareTo(Airline o) {
  25.        if(this.destinations < o.destinations) return -1;
  26.        else if(this.destinations > o.destinations) return 1;
  27.        else return 0;
  28.    }
  29.    
  30. }
  31. ////////////////////////////////////////////////////////////////////////////////
  32.  
  33. class SortAirlinesByCapacity implements Comparator<Airline> {
  34.     public int compare(Airline a1, Airline a2) {
  35.         ;
  36.     }
  37. }
  38. ////////////////////////////////////////////////////////////////////////////////
  39.  
  40. public class NewMain {
  41.  
  42.     /**
  43.      * @param args the command line arguments
  44.      */
  45.     public static void main(String[] args) throws FileNotFoundException {
  46.         ArrayList<Airline> alObj = new ArrayList<Airline>();
  47.         String infile = "airlines.txt";
  48.         try (Scanner scanfile = new Scanner(new File(infile))) {
  49.              while(scanfile.hasNext()) {
  50.                  
  51.              }
  52.         }
  53.         catch(FileNotFoundException e) {
  54.             System.err.println("An error occurs. End program.");
  55.             System.exit(-1);
  56.         }
  57.        
  58.         System.out.printf("Sort by [d = default, c = capacity, t = timeline, q = quit] >> ");
  59.         Scanner scan = new Scanner(System.in);
  60.         char choices = scan.next().charAt(0);
  61.         switch(Character.toUpperCase(choices)) {
  62.             case 'C':
  63.                 System.out.println("C");
  64.                 break;
  65.             case 'D':
  66.                 System.out.println("D");
  67.                 break;
  68.             case 'T':
  69.                 System.out.println("T");
  70.                 break;
  71.         }
  72.        
  73.     }
  74.    
  75. }
Add Comment
Please, Sign In to add comment