Samorokimetal

App 15.11.2020

Nov 14th, 2020 (edited)
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1. public class App {
  2.    
  3.     public static void main(String[] args) {
  4.         Car[] carsInput = new Car[5];
  5.         carsInput[0] = new Car("Toyota", "Supra", "red", 321, "V6", "5-speed manual", 1999);
  6.         carsInput[1] = new Car("Audi", "A8l", "black", 340, "V8", "6-speed automatic", 2018);
  7.         carsInput[2] = new Car("BMW", "E60", "white", 250, "V6", "6-speed manual", 2010);
  8.         carsInput[3] = new Car("BMW", "E60", "white", 250, "V6", "6-speed manual", 2010);
  9.         carsInput[4] = new Car("Audi", "A6", "black", 250, "V6", "6-speed automatic", 2016);
  10.  
  11.         System.out.println("Input: ");
  12.         for (int i = 0; i < carsInput.length; i++) {
  13.             System.out.println(carsInput[i]);
  14.         }
  15.         System.out.println();
  16.  
  17.         Car[] cars = Car.deleteRepetitiveCars(carsInput);
  18.         System.out.println("Cars after removing the repetitive ones (if any): ");
  19.         for (int i = 0; i < cars.length; i++) {
  20.             System.out.println(cars[i]);
  21.         }
  22.         System.out.println();
  23.  
  24.         char letter = 'Q';
  25.         Car[] carBrandChanged = Car.changeFirstLetterOfBrand(cars, letter);
  26.         System.out.println("Cars after changing brand name: ");
  27.         for (int i = 0; i < cars.length; i++) {
  28.             System.out.println(carBrandChanged[i]);
  29.         }
  30.         System.out.println();
  31.  
  32.         String sortBy = "ascending";
  33.         Car[] sortedCarsByBrand = Car.sortCarsByBrandName(cars, sortBy);
  34.         System.out.printf("Cars after sorting by brand name %s: \n", sortBy);
  35.         for (int i = 0; i < cars.length; i++) {
  36.             System.out.println(sortedCarsByBrand[i]);
  37.         }
  38.     }
  39. }
Add Comment
Please, Sign In to add comment