public static void main(String[] args)
Scanner scan = new Scanner(System.in);
ArrayList<Car> dude = new ArrayList<Car>();
ArrayList<ElectricCar> dude2 = new ArrayList<ElectricCar>();
9.6.7 cars PasteShr 9.6.7 cars
System.out.println("Please enter a car model name(exit to quit): ");
String bruh1 = scan.nextLine();
if (bruh1.equals("exit"))
Car car = new Car(bruh1, null);
for (int i = 0; i < dude.size(); i++)
9.6.7 cars PasteShr 9.6.7 cars
System.out.println(dude.get(i));//dude.get(i));
System.out.println(dude.get(i).getMPG());
9.6.7 cars PasteShr 9.6.7 cars
System.out.println("Is this car electric? (y or n) ");
String bruh2 = scan.nextLine();
ElectricCar car = new ElectricCar(bruh1);
9.6.7 cars PasteShr 9.6.7 cars
else if (bruh2.equals("n"))
System.out.println("How many miles per gallon: ");
String bruh4 = scan.nextLine();
Car car = new Car(bruh1, bruh4);
9.6.7 cars How to get it? 9.6.7 cars
9.6.7 cars PasteShr 9.6.7 cars
public Car(String model, String mpg){
public String getModel(){
9.6.7 cars How to get it for free? 9.6.7 cars
public String toString(){
//return "\n" + model + " gets " + mpg + " mpg.";
9.6.7 cars PasteShr 9.6.7 cars
public class ElectricCar extends Car
public ElectricCar(String model)
9.6.7 cars How to use it? 9.6.7 cars
// Override the getMPG here.
// It should return: "Electric cars do not calculate MPG.
return "MPG: Electric cars do not calculate MPG";
// Override the toString() here.
// (model) is an electric car.
9.6.7 cars PasteShr 9.6.7 cars
//return "\n" + super.getModel() + " is an electric car.";
return "Car: " + super.getModel();