Challenge: Selecting the Best Cars on the Production Line
Swipe to start coding
At the factory, you need to process a list of cars, filter them based on mileage, sort them according to specific criteria, and display the results.
Each car is represented by the Car
class, which contains an id
as a unique identifier, a model
specifying the car’s name, a year
indicating when it was manufactured, and a mileage
field representing the total distance it has traveled.
- Filter the cars, keeping only those with a mileage of 30,000 miles or less using the
filter()
method. - Sort the cars by
year
in ascending order usingcomparingInt()
method. - Once the cars are sorted by
year
, reverse the order to have the newest cars first usingreversed()
method. - If two cars have the same
year
, sort them bymileage
in ascending order usingthenComparing()
method. - Convert each car object to a string representation, using the
toString()
method. - Print the final list to the console, using a method reference to
println()
.
Oplossing
solution.java
Bedankt voor je feedback!
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Awesome!
Completion rate improved to 2.33Awesome!
Completion rate improved to 2.33
Challenge: Selecting the Best Cars on the Production Line
Swipe to start coding
At the factory, you need to process a list of cars, filter them based on mileage, sort them according to specific criteria, and display the results.
Each car is represented by the Car
class, which contains an id
as a unique identifier, a model
specifying the car’s name, a year
indicating when it was manufactured, and a mileage
field representing the total distance it has traveled.
- Filter the cars, keeping only those with a mileage of 30,000 miles or less using the
filter()
method. - Sort the cars by
year
in ascending order usingcomparingInt()
method. - Once the cars are sorted by
year
, reverse the order to have the newest cars first usingreversed()
method. - If two cars have the same
year
, sort them bymileage
in ascending order usingthenComparing()
method. - Convert each car object to a string representation, using the
toString()
method. - Print the final list to the console, using a method reference to
println()
.
Oplossing
solution.java
Bedankt voor je feedback!
single
Awesome!
Completion rate improved to 2.33
Challenge: Selecting the Best Cars on the Production Line
Veeg om het menu te tonen
Swipe to start coding
At the factory, you need to process a list of cars, filter them based on mileage, sort them according to specific criteria, and display the results.
Each car is represented by the Car
class, which contains an id
as a unique identifier, a model
specifying the car’s name, a year
indicating when it was manufactured, and a mileage
field representing the total distance it has traveled.
- Filter the cars, keeping only those with a mileage of 30,000 miles or less using the
filter()
method. - Sort the cars by
year
in ascending order usingcomparingInt()
method. - Once the cars are sorted by
year
, reverse the order to have the newest cars first usingreversed()
method. - If two cars have the same
year
, sort them bymileage
in ascending order usingthenComparing()
method. - Convert each car object to a string representation, using the
toString()
method. - Print the final list to the console, using a method reference to
println()
.
Oplossing
solution.java
Bedankt voor je feedback!