Question
Create a new IntelliJ project called ElectricCarsList and add an empty public static void main method. a. Create an ArrayList and create a method to
Create a new IntelliJ project called ElectricCarsList and add an empty public static void main method.
a. Create an ArrayList
b. Now let's add more information to make your list more interesting by following the instructions below to print out your revised list:
Step 1: Add an internal class to your ElectricalCars class something like the following; public class ElectricCarList { ArrayList
Step 2: From inside your Electric Car class code in the IntelliJ editor, right-mouse-click in the IntelliJ editor and select the Generate menu item (or press Alt-Insert). Generate getters for all attributes. Right-mouse-click and select Generate again and create a Constructor. Call Generate again and create a toString method. Your ElectricCar class should now have getters for all attributes, a toString() method that you can call to list the names and values of all the attributes, and a Constructor for populating the class object.
Step 3: Add a method to ElectricCarList to populate your ArrayList
public void addCars() { carList.add(new ElectricCar("2020 Tesla Model S", 74990, 402, 9.0,1)); // You add code to add the other cars to your list }
public static void main(String[] args) { // Create a car list, populate, and print it out ElectricCarList cars = new ElectricCarList(); cars.addCars(); cars.printList(); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started