Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class App {
- public static void main(String[] args) {
- Car[] carsInput = new Car[5];
- carsInput[0] = new Car("Toyota", "Supra", "red", 321, "V6", "5-speed manual", 1999);
- carsInput[1] = new Car("Audi", "A8l", "black", 340, "V8", "6-speed automatic", 2018);
- carsInput[2] = new Car("BMW", "E60", "white", 250, "V6", "6-speed manual", 2010);
- carsInput[3] = new Car("BMW", "E60", "white", 250, "V6", "6-speed manual", 2010);
- carsInput[4] = new Car("Audi", "A6", "black", 250, "V6", "6-speed automatic", 2016);
- System.out.println("Input: ");
- for (int i = 0; i < carsInput.length; i++) {
- System.out.println(carsInput[i]);
- }
- System.out.println();
- Car[] cars = Car.deleteRepetitiveCars(carsInput);
- System.out.println("Cars after removing the repetitive ones (if any): ");
- for (int i = 0; i < cars.length; i++) {
- System.out.println(cars[i]);
- }
- System.out.println();
- char letter = 'Q';
- Car[] carBrandChanged = Car.changeFirstLetterOfBrand(cars, letter);
- System.out.println("Cars after changing brand name: ");
- for (int i = 0; i < cars.length; i++) {
- System.out.println(carBrandChanged[i]);
- }
- System.out.println();
- String sortBy = "ascending";
- Car[] sortedCarsByBrand = Car.sortCarsByBrandName(cars, sortBy);
- System.out.printf("Cars after sorting by brand name %s: \n", sortBy);
- for (int i = 0; i < cars.length; i++) {
- System.out.println(sortedCarsByBrand[i]);
- }
- }
- }
Add Comment
Please, Sign In to add comment