Question: For todays lab you will create a java project that will contain a main class called Tester and a Class called Car . Your Car

For todays lab you will create a java project that will contain a main class called Tester and a Class called Car.

Your Car class should contain the following:

1.Properties make these private

owner, make, model, year

Methods make these public and write out the code

a)Constructors

1.Empty

2.Workhorse

3.Copy

b)Clone

c) getters and setters for your properties.

1)Note: make sure the year cannot be set less than 1940 or greater than 2018

d)save() and read()

e)toString() this should return a well formatted string.

Your Testers file should do the following:

1)Put yours and your partners name at the top of the file.

2)Your main should read (so add throws Exception to the end): public static void main(String[] args) throws Exception { }

3)Create 3 Car objects (car1, car2, car3):

Use the empty constructor for the 1st Car and fill out the properties

Use the workhorse constructor for the 2nd Car

Use the copy constructor for the 3rd Car to copy car1

4)Change car3 year and owner

5)Print each car

6)Change car1s year to 2050 and print car1 again

7)Create a PrintWriter object that opens a text file called cars.txt.

8)Call the save for each car and then close the PrintWriter

9)Set all cars equal to new Car()

10)Print all 3 cars to make sure all data is cleared

11)Create a Scanner can call each cars read() method. Close the Scanner

12)Print all 3 cars to make sure all data has been read back in.

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!