import java.util.*;

public class Reservation implements Observer.UseObserverAspect {

    private PricingStrategy pricingStrategy;
    private Vector flights;

    public long pennies() {
        return getTotal().pennies();
    }

    public String description() {
        return "a reservation";
    }

    public Money getTotal() {
        return pricingStrategy.getTotal(this);
    }

    public Money getPreDiscountTotal() {
        Money tot = new Money();
        for (int i = 0; i < flights.size(); i++) {
            tot = tot.add(((Flight)flights.elementAt(i)).getTotal());
        }
        return tot;
    }

    public boolean contains(City c) {
        Money tot = new Money();
        for (int i = 0; i < flights.size(); i++) {
            if (((Flight)flights.elementAt(i)).contains(c)) {
                return true;
            }
        }
        return false;
    }

    public void enterFlight(Flight f) {
        flights.add(f);
    }

    Reservation(PricingStrategy ps) {
        this.pricingStrategy = ps;
        flights = new Vector();
    }

    public Object clone() {
        Reservation r = new Reservation(pricingStrategy);
        r.flights = (Vector)flights.clone();
        return r;
    }

};
