Question: Need help to compare with my code. Write a Vehicle class. An automobile has a year and manufacturer. Implement at least one constructor that takes

Need help to compare with my code.

Write a Vehicle class. An automobile has a year and manufacturer. Implement at least one constructor that takes a year and manufacture name.

Write a Car class. A car is a vehicle but also has a MPG. A car is comparable based on their MPGs. Implement at least one constructor that takes year, manufacturer and MPG, and the method for comparing cars.

In the main method, create a list of 3 cars of your choice, then sort the cars by their MPGs. Also in the main method, create an array of 3 cars of your choice, then sort the cars by their manufacturers names. You must use a comparator this time, and use the anonymous inner class style.

Finally, sort the cars by their years using lambda expression style.

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!