Prenotazione.java
Created with JBuilder
class Prenotazione {
  // Attributi
  private String codiceVolo;
  private String  partenza, destinazione;
  private int     numeroPostiPrenotati;
  private Posto[] elencoPosti;

  // Costruttore
  public Prenotazione(String c, String p, String d,
               int numeroMaxPrenotazioni) {
    codiceVolo = c;
    partenza = p;
    destinazione = d;
    elencoPosti = new Posto[numeroMaxPrenotazioni];
    numeroPostiPrenotati = 0;
  }

  // Metodi di restituzione
  public Posto[] restituisciPosti() {
    return elencoPosti;
  }
  public int restituisciNumeroPostiPrenotati() {
    return numeroPostiPrenotati;
  }
  public String restituisciCodiceVolo() {
    return codiceVolo;
  }
  public String restituisciDestinazione() {
    return destinazione;
  }

  // Aggiunta di un posto
  public boolean aggiungi(Posto p) {
    if (numeroPostiPrenotati < elencoPosti.length) {
      elencoPosti[numeroPostiPrenotati] = p;
      ++numeroPostiPrenotati;
      return true;
    } else {
      return false;
    }
  }

  // Cancellazione di un posto prenotato
  public boolean cancellaPosto(String passaportoCercato) {
    for (int i = 0; i < numeroPostiPrenotati; ++i ) {
      String passaportoTrovato = elencoPosti[i].restituisciPassaporto();
      if (passaportoTrovato.equals(passaportoCercato)) {
        elencoPosti[i] = elencoPosti[numeroPostiPrenotati - 1];
        --numeroPostiPrenotati;
        return true;
      }
    }
    return false;
  }

  // Restituzione del numero di pasti dato il tipo
  public int numeroPastiPerTipo(int tipo) {
    int numeroPerTipo = 0;
    for (int i = 0; i < numeroPostiPrenotati; ++i) {
      if (elencoPosti[i].restituisciTipoPasto()== tipo) {
        ++numeroPerTipo;
      }
    }
    return numeroPerTipo;
  }
}

Prenotazione.java
Created with JBuilder