/**
 * COSC 60 Demo
 * Inheritance Example
 * @author Adam Koehler
 * @version 1.0,  &nbsp; 2008 Oct 22
 */
public class Automobile extends Vehicle
{
    private int tankSize;
    private int milesPerGal;

    /* driver... unsafe scenario? */
    private int seatBelts;
    

    public Automobile()
    {
        this(4,5,0,0);
    }
    public Automobile(int w, int o, int s, int mpg)
    {
        super(w,o);
        tankSize = s;
        milesPerGal = mpg;
        seatBelts = o;
    }

    public void setTankSize(int s)
    {
        tankSize = s;
    }

    public int getTankSize()
    {
        return tankSize;
    }
    public void setWheels(int mpg)
    {
        milesPerGal = mpg;
    }

    public int getMPG()
    {
        return milesPerGal;
    }


    /* Needed? */
    public boolean insertPassenger()
    {
        return addOcc();
    }

    public boolean addOcc(int howMany)
    {
        boolean result = false;
        
        /* this fails 
        if(!((filledSpots + howmany) < occupants))
            result = false;
        else
        {
            filledSpots += howmany;
            result = true;
        }
        */
      
        if(!((getFilledSpots() + howMany) <= getOccupants()))
            result = false;
        else
        {
            for(int i=0; i<howMany; i++)
                addOcc();
            result = true;
        }
        return result;
    }

    /* Unsafe driver scenario -- overriding */
    public boolean full()
    {
        return (getFilledSpots() >= (seatBelts + 2));
    }
   
    public static void main(String[] args)
    {
        Vehicle myV = new Vehicle(4, 5);
        Automobile myA = new Automobile(4, 5, 14, 22);

        myV.addOcc();
        myA.addOcc();
        
        System.out.println("Current occupants in vehicle: "+
                             myV.getFilledSpots());
        System.out.println("Current occupants in auto: "+
                             myA.getFilledSpots());
        myV.addOcc();
        myV.addOcc();
        myV.addOcc();
        myV.addOcc();
        myA.addOcc(4);

        System.out.println("Current occupants in vehicle: "+
                             myV.getFilledSpots());
        System.out.println("Current occupants in auto: "+
                             myA.getFilledSpots());


        System.out.println("Vehicle full? = " + myV.full());

        System.out.println("Auto full? = " + myA.full());
        

    }
}

