Question: please just do the writetotextfileand readfromtextfile please just do the writetotextfileand readfromtextfile please just do the writetotextfileand readfromtextfile 2. [2.5 pts] Consider the class Car

please just do the "writetotextfile"and "readfromtextfile"

please just do the "writetotextfile"and "readfromtextfile"

please just do the "writetotextfile"and "readfromtextfile" please just do the "writetotextfile"and "readfromtextfile" please just do the "writetotextfile"and

2. [2.5 pts] Consider the class Car that implements Serializable. The Car class has three attributes plateNumber, make, and price. - Use the following code of the CarTester class and accordingly write the required code in class CarRep. - Compile and run the code. You should have this output: import java util_Arravlisti public class GarTester \{ public CarTesterf) \& Arraylist cars = new Arraylist(); cars.add(new Car("A123", "Toyota", 50000)); cars.addinew Car("B123", "Honda", 40000)); cars.add(new Car("C123", "Nissan", 60000)); cars.add(new Car("D123", "Ford", 30000)); //Write the objects of the list "theGars" to the file "Garsfile" as objects. CarRegow writeToQbiEile("carsfile", cars); // Read the cars objects from the file "carsfile" into the list "the Cars" Arraylisk theGars; theCars = CarRepo, read Erom QbiFile("carsfile"); for(Car c : theGars) \& Sxstem.out.print|n(c.tostring()); \} //modify some the second car object by adding 2000 to the price. the Cars.get(1). setprice(therars.get (1).getprice(1)+2000); //write the data of the cars objects of the list "thecars" to a text file "carsfile.txt" CarReporwriteteTextfile("carsfile.txt", theCars); //Read the data of the cars object from the text file "carsfile.txt" into the list theCars2. Arraylist theCars2 = CarReporvedd fromTextFile("carsfile.txt"); //Add the car objects of the list "theCars2" to the list "theGass" for(Car c : the Cars2) \& theCars.add(c); \} //Display the contents of the list "theCars". for(Car c : theCars) \& System.out.println(c.tostring()); \} 3 public static void main(String[] args) \{ new CarTester(); \}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!