Open klaw772 opened 2 weeks ago
I found DocInDocs's solution: https://exercism.org/tracks/java/exercises/need-for-speed/solutions/DocInDocs
They create this new function inside Class Car.
public boolean canFinishRace(int distance) {
return distance * this.batteryDrain / this.speed <= 100;
}
Some chose to create getSpeed() and getBattery() instead.
For example, heptalophos'solution: https://exercism.org/tracks/java/exercises/need-for-speed/solutions/heptalophos
When completing Need for Speed, the recommendation from the analyzer was as follows: "Instead of using a loop, consider returning a single expression using the <= operator. You can re-use the other methods already implemented in the class."
However, in the instructions of the exercise, the Task 6 implementation example shows that the distance driven by the car is increasing, along with the track completion being evaluated. This distance increase shown in the example seems like drive() needs to be repeatedly called using something like a loop, rather than only using a single expression to check track completion.