import java.util.ArrayList;
import java.util.Collections;

public class VehicleSorter{
    public static void main( String[] args ){
        Vehicle oldie = new Vehicle("Ford", "Mustang", 1986, 9000.00);
        Vehicle prius = new Vehicle("Toyota", "Prius", 2010, 7750.00);
        Vehicle stringRay = new Vehicle("Chevrolet", "Corvette", 1960, 100_000.00);

        ArrayList<Vehicle> cars = new ArrayList<Vehicle>();
        cars.add( oldie );
        cars.add( prius );
        cars.add( stringRay );

        System.out.println("Unsorted: " + cars );

        // uses the Comparable interface
        Collections.sort( cars );

        System.out.println("Sorted (by make): " + cars );

        /*
         * Using objects that implement the Comparator interface
         */
        VehiclePriceComparator priceComparator = new VehiclePriceComparator();
        cars.sort( priceComparator );
        System.out.println("Sorted (by price): " + cars );

        VehicleYearPerPriceComparator yearPerPriceComparator = new VehicleYearPerPriceComparator();
        cars.sort( yearPerPriceComparator );
        System.out.println("Sorted (year per price): " + cars );
    }
}