spiny94

Untitled

Sep 2nd, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.48 KB | None | 0 0
  1. package Aerei;
  2.  
  3. public class Volo implements Comparable<Volo> {
  4.         private String cod;
  5.         private String giorno;
  6. private String aer;
  7. private String part;
  8.         private String arr;
  9.         public Volo(String cod, String aer, String part, String arr,
  10.                 String giorno) {
  11.        
  12.         this.cod=cod;
  13.         this.aer=aer;
  14.         this.part=part;
  15.         this.arr=arr;
  16.         this.giorno=giorno;
  17.         // TODO Auto-generated constructor stub
  18.         }
  19.  
  20. package Aerei;
  21. import java.util.Collections;
  22. import java.util.HashMap;
  23. import java.util.LinkedList;
  24. import java.util.List;
  25. import java.util.Map;
  26. import java.util.TreeMap;
  27.  
  28.  
  29. public class Compagnia {
  30.     Map<String,Aereo> aerei = new TreeMap<String,Aereo>();
  31.     Map<String,Volo> voli = new TreeMap<String, Volo>();
  32.     private int PostiLiberi;
  33.     private String nome;
  34.     private AeroportiMondo am;
  35.         //List<AeroportiMondo> ap = new LinkedList<AeroportiMondo>();
  36.            
  37.         public Compagnia(String nome, AeroportiMondo am){
  38.     this.nome=nome;
  39.     this.am=am;
  40.    
  41.     }
  42.    
  43.     public void addAereo(String cod, int pass) throws InvalidCode {
  44.         Aereo ar = new Aereo(cod,pass);
  45.        
  46.         if ( aerei.containsKey(cod)) throw new InvalidCode();
  47.         aerei.put(cod, ar);
  48.        
  49.     }
  50.    
  51.     public List<String> getAerei(){
  52.         List<String> res = new LinkedList<String>(aerei.keySet());
  53.         Collections.sort(res);
  54.         return res;
  55.     }
  56.    
  57.     public void addVolo(String cod, String aer, String part, String arr, String giorno) throws InvalidCode {
  58.      Volo vol = new Volo(cod, aer, part, arr, giorno);
  59.      voli.put(cod, vol);
  60.      if (voli.containsKey(cod)) throw new InvalidCode();
  61.      
  62.        
  63.     }
  64.    
  65.     public void cancelVolo(String cod) throws InvalidCode {
  66.     if (!voli.containsKey(cod)) throw new InvalidCode();
  67.     voli.remove(cod);
  68.     }
  69.    
  70.     public List<Volo> getVoli(){
  71.         return new LinkedList<Volo>(voli.values());
  72.        
  73.        
  74.     }
  75.    
  76.     public boolean prenota(int num, String cod) throws InvalidCode {
  77.         if ( ! aerei.containsKey(cod)) throw new InvalidCode();
  78.         if( aerei.containsKey(cod) && aerei.containsValue(ar.pass) < num )
  79.         return true;
  80.         else return false;
  81.     }
  82.    
  83.     public int postiLiberi(String cod) throws InvalidCode {
  84.         if ( ! aerei.containsKey(cod)) throw new InvalidCode();
  85.         return PostiLiberi;
  86.     }
  87.    
  88.     public void partitoVolo(String cod, int ritardo) throws InvalidCode {
  89.     }
  90.    
  91.     public void arrivatoVolo(String cod, int ritardo) throws InvalidCode {
  92.     }
  93.        
  94.     public List<String> ritardiPartenza() {
  95.         return null;
  96.     }
  97.    
  98.     public List<String> ritardiArrivo() {
  99.         return null;
  100.     }
  101.    
  102.     public List<String> voliCritici() {
  103.         return null;
  104.     }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment