package hw05;

public class TryCar {

	public static void main(String[] args) {
		Car[] cars = new Car[5]; // Top five cars
		cars[0]=new Car("Aston Martin","DB5",1964,new FullName("James","","Bond"));
		cars[1]=new Car("George Barris","BatMobile", 1963,new FullName("Bruce","","Wayne"));
		cars[2]=new Car("Rolls Royce","Phantom V",1965,new FullName("John","Winston","Lennon") );
		cars[3]=new Car("Mercedes Benz","300SL Gullwing",1955,new FullName("Clark","","Gable"));
		cars[4]=new Car("Deusenberg","Model J",1931,new FullName("Phil","","Berg"));
		
		System.out.println("Top Five Cars:");
		printCars(cars);
		
		BinaryTree byDate = new BinaryTree(cars[0]);
		for (int i=1; i<cars.length; i++) {
			byDate.insertByDate(cars[i]);
		}
		
		System.out.println("\nCars by year...");
		byDate.printGraph();
		System.out.println("Size=" + byDate.size() + " depth=" + byDate.depth() + 
				" position of cars[4]=" + byDate.position(cars[4]));
		
		BinaryTree byMake = new BinaryTree(cars[0]);
		for (int i=1; i<cars.length; i++) {
			byMake.insertByMake(cars[i]);
		}
		
		System.out.println("\nCars by make...");
		byMake.printGraph();
		System.out.println("Size=" + byMake.size() + " depth=" + byMake.depth() + 
				" position of cars[4]=" + byMake.position(cars[4]));
		
		BinaryTree byOwner = new BinaryTree(cars[0]);
		for (int i=1; i<cars.length; i++) {
			byOwner.insertByOwner(cars[i]);
		}
		
		System.out.println("\nCars by owner...");
		byOwner.printGraph();
		System.out.println("Size=" + byOwner.size() + " depth=" + byOwner.depth() + 
				" position of cars[4]=" + byOwner.position(cars[4]));
		
				
	}
	
	private static void printCars(Car[] cars) {
		for(int i=0;i<cars.length;i++) {
			System.out.println("" + i + " : " + cars[i]);			
		}
	}

}

