package model;

/**
 * Created by Gondr on 28/05/2017.
 */
public class SharedTrip extends Trip {

    private int seatsAvailable;

    private String[] userBookings;

    public SharedTrip (Trip trip, int seatsAvailable){
        super(trip.name, trip.route, trip.direction, trip.ride, trip.days, trip.reoccur, trip.endDate);
        userBookings = new String[this.ride.getNumSeats() - 1];
        this.seatsAvailable = seatsAvailable;
    }

    public String getDays(){
        String daysString = "";
        for (int i = 0; i < 7; i++){
            if (days[i] == true){
                daysString += Days.getValue(i).dayName + ", ";
            }
        }
        if (daysString.length() != 0){
            daysString = daysString.substring(0, daysString.length() - 2);
        }
        return daysString;
    }

    public int getSeatsAvailable() {
        return seatsAvailable;
    }

    public void bookSeat(String user){
        userBookings[ride.getNumSeats() - seatsAvailable - 1] = user;
        seatsAvailable -= 1;
    }

    public boolean isFull(){
        return seatsAvailable == 0;
    }

}
