Advertisement
Guest User

AECar Driver

a guest
Mar 22nd, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Collections;
  3.  
  4. public class Driver {
  5.     public static void main(String[] args) {
  6.         AECar eCar1 = new Pluggable("Chevy", "Volt", true, 33520, 18.4, true);
  7.         AECar eCar2 = new Battery("Kia", "Soul", false, 17490, 30, 3);
  8.         AECar afCar1 = new Hydrogen("Honda", "Clarity", false, 36620, 7, "null");
  9.         AECar afCar2 = new Biofuel("Chevy", "Cruze", false, 17995, 13.5, "null");
  10.  
  11.         ArrayList<AECar> CarList = new ArrayList<AECar>();
  12.         CarList.add(eCar1);
  13.         CarList.add(eCar2);
  14.         CarList.add(afCar1);
  15.         CarList.add(afCar2);
  16.  
  17.         Collections.sort(CarList);
  18.         System.out.println(CarList);
  19.  
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement