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
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