9.6.7 cars //tester import java.util.*; public class CarTester { public static void main(String[] args) { Scanner scan = new Scanner(System.in); //int i = 0; ArrayList dude = new ArrayList(); ArrayList dude2 = new ArrayList(); 9.6.7 cars PasteShr 9.6.7 cars while (true) { 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()); if (i < dude.size() ) { System.out.println(); } } break; 9.6.7 cars PasteShr 9.6.7 cars } System.out.println("Is this car electric? (y or n) "); String bruh2 = scan.nextLine(); if (bruh2.equals("y")) { ElectricCar car = new ElectricCar(bruh1); dude.add(car); } 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); dude.add(car); } 9.6.7 cars How to get it? 9.6.7 cars } } } //car public class Car { //This code is complete private String model; private String mpg; 9.6.7 cars PasteShr 9.6.7 cars public Car(String model, String mpg){ this.model = model; this.mpg = mpg; } public String getModel(){ return model; } 9.6.7 cars How to get it for free? 9.6.7 cars public String getMPG(){ return "MPG: " + mpg; } public String toString(){ //return "\n" + model + " gets " + mpg + " mpg."; return "Car: " + model; } } 9.6.7 cars PasteShr 9.6.7 cars //electiccar public class ElectricCar extends Car { public ElectricCar(String model) { super(model, ""); } @Override 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. public String getMPG() { return "MPG: Electric cars do not calculate MPG"; } // Override the toString() here. // (model) is an electric car. public String toString() 9.6.7 cars PasteShr 9.6.7 cars { //return "\n" + super.getModel() + " is an electric car."; return "Car: " + super.getModel(); } } 9.6.7 cars