Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Aerei;
- public class Volo implements Comparable<Volo> {
- private String cod;
- private String giorno;
- private String aer;
- private String part;
- private String arr;
- public Volo(String cod, String aer, String part, String arr,
- String giorno) {
- this.cod=cod;
- this.aer=aer;
- this.part=part;
- this.arr=arr;
- this.giorno=giorno;
- // TODO Auto-generated constructor stub
- }
- package Aerei;
- import java.util.Collections;
- import java.util.HashMap;
- import java.util.LinkedList;
- import java.util.List;
- import java.util.Map;
- import java.util.TreeMap;
- public class Compagnia {
- Map<String,Aereo> aerei = new TreeMap<String,Aereo>();
- Map<String,Volo> voli = new TreeMap<String, Volo>();
- private int PostiLiberi;
- private String nome;
- private AeroportiMondo am;
- //List<AeroportiMondo> ap = new LinkedList<AeroportiMondo>();
- public Compagnia(String nome, AeroportiMondo am){
- this.nome=nome;
- this.am=am;
- }
- public void addAereo(String cod, int pass) throws InvalidCode {
- Aereo ar = new Aereo(cod,pass);
- if ( aerei.containsKey(cod)) throw new InvalidCode();
- aerei.put(cod, ar);
- }
- public List<String> getAerei(){
- List<String> res = new LinkedList<String>(aerei.keySet());
- Collections.sort(res);
- return res;
- }
- public void addVolo(String cod, String aer, String part, String arr, String giorno) throws InvalidCode {
- Volo vol = new Volo(cod, aer, part, arr, giorno);
- voli.put(cod, vol);
- if (voli.containsKey(cod)) throw new InvalidCode();
- }
- public void cancelVolo(String cod) throws InvalidCode {
- if (!voli.containsKey(cod)) throw new InvalidCode();
- voli.remove(cod);
- }
- public List<Volo> getVoli(){
- return new LinkedList<Volo>(voli.values());
- }
- public boolean prenota(int num, String cod) throws InvalidCode {
- if ( ! aerei.containsKey(cod)) throw new InvalidCode();
- if( aerei.containsKey(cod) && aerei.containsValue(ar.pass) < num )
- return true;
- else return false;
- }
- public int postiLiberi(String cod) throws InvalidCode {
- if ( ! aerei.containsKey(cod)) throw new InvalidCode();
- return PostiLiberi;
- }
- public void partitoVolo(String cod, int ritardo) throws InvalidCode {
- }
- public void arrivatoVolo(String cod, int ritardo) throws InvalidCode {
- }
- public List<String> ritardiPartenza() {
- return null;
- }
- public List<String> ritardiArrivo() {
- return null;
- }
- public List<String> voliCritici() {
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment