import java.util.*;

public class VehicleMain {
  public static void main(String[] args) {
    Automobile car1 = new Automobile("Chevrolet", "Cruze", 2011, "1G1JF27W8GJ178227");
    Automobile car2 = new Automobile("Ford", "Taurus", 2010, "1G1KK13WBB265789");
    Truck truck1 = new Truck("Toyota", 3, "1H123");
    ArrayList<Vehicle> stock = new ArrayList<Vehicle>();
    stock.add(car1);
    stock.add(truck1);
    stock.add(car2);
    
    // count Fords
    int countFords = 0;
    for (int i = 0; i < stock.size(); i++) {
      if (stock.get(i).getMake().equals("Ford")) {
        countFords++;
      }
    }
    System.out.println("#Fords = " + countFords);

    // find VIN 1H123
    for (int i = 0; i < stock.size(); i++) {
      if (stock.get(i).getVIN().equals("1H123")) {
	  System.out.println(" found VIN 1H123 at i = " + i);
      }
    }

    // find oldest car's year
    int oldYear = 2020;  // start high
    for (int i=0; i< stock.size(); i++) {
	if (stock.get(i) instanceof Automobile) {
	    Automobile car = (Automobile)stock.get(i);
	    if (car.getYear() < oldYear) {
		oldYear = car.getYear();
	    }
	}
    }
    System.out.println("oldest car's year is "+ oldYear);
  }
} 
    
