/** * This program tests the Vehicle project. * This is the THIRD version of an application program that your program should be able to run. * * @author (your name) * @version (a version number or a date) */ public class VehicleTesting2 { public static void main(String[] args) { Vehicle[] vehicleList = Utility.read("vehicleData.txt", 20); Utility.printVehicleList(vehicleList); // print the entire list // Print the average price, number of trucks, # of convertibles System.out.println("The average price of a car is $" + Utility.averagePrice(vehicleList)); // rounded to 2 decimal places System.out.println(""); System.out.println("Number of trucks: " + Utility.numberOfTrucks(vehicleList)); // display the number of truc System.out.println("Number of convertibles: " + Utility.numberOfConvertibles(vehicleList)); // display the number of convertible // Display all of a particular make String makeToFind = "Jeep"; // try this with different makes - even makes that don't exist! Utility.printVehicleList(Utility.allOfMake(makeToFind,vehicleList)); // Sorting Methods System.out.println("================================================"); System.out.println("*Sorted by Price*"); Utility.printVehicleList(Utility.sortByPrice(vehicleList, "ASC")); // try with "DESC" System.out.println("================================================"); System.out.println("*Sorted by Name*"); Utility.printVehicleList(Utility.sortByName(vehicleList, "ASC")); // try with "DESC" System.out.println("================================================"); System.out.println("*Sorted by Efficiency*"); Vehicle[] efficiencyOrder = Utility.sortByEfficiency(vehicleList, "ASC"); Utility.printVehicleList(efficiencyOrder); // Insert one by efficiency - first create the new vehicle, then add it Vehicle newVehicle = new Car(); // FILL IN THIS CONSTRUCTOR vehicleList = Utility.insertOneByEfficiency(vehicleList, newVehicle); Utility.printVehicleList(vehicleList); // ensure the new car is in the correct place }//================================================================================= }