Advertisement
spiny94

Untitled

Sep 2nd, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. package Aerei;
  2.  
  3. import java.util.HashMap;
  4. import java.util.Map;
  5.  
  6.  
  7. public class AeroportiMondo {
  8.     Map<String, Aeroporto> aeroporti = new HashMap<String, Aeroporto>();
  9.    
  10.     public void addAeroporto(Aeroporto arpt) throws InvalidCode{
  11.    
  12. String cod = arpt.getCode();
  13. if (aeroporti.containsKey(cod)){throw new InvalidCode();}
  14. aeroporti.put(cod, arpt);
  15.    
  16.     }
  17.    
  18.     public  void removeAeroporto(String cod) {
  19.     aeroporti.remove(cod);
  20.    
  21.     }
  22.    
  23.     public  Aeroporto getAeroporto(String cod) {
  24.        
  25.     if ( !  aeroporti.containsKey(cod)) return null;
  26.         return aeroporti.get(aeroporti);
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement