exercism / java

Exercism exercises in Java.
https://exercism.org/tracks/java
MIT License
677 stars 666 forks source link

Inconsistency between Need for Speed task 6 analyzer feedback and instructions #2737

Closed kahgoh closed 4 months ago

kahgoh commented 4 months ago

I think the Need for Speed's task 6's instruction is out of sync with the analyzer feedback. More specifically, I think it is this one:

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.

The part of the solution that produces this:

class RaceTrack {
    // ...
    public boolean tryFinishTrack(NeedForSpeed car) {
        while (!car.batteryDrained() && car.distanceDriven() <= this.distance){
            car.drive();
        }
        return car.distanceDriven() >= this.distance;
    }
}

The exemplar solution uses a mathematical formula in tryFinishTrack:

public boolean tryFinishTrack(NeedForSpeed car) {
    throw new UnsupportedOperationException("Please implement the RaceTrack.tryFinishTrack() method");
}

I no longer get the analyzer feedback when I change to this implementation. But, I think this is inconsistent with the current instructions, as I think it encourages students to continually call drive as per the while loop approach:

6. Check if a remote control car can finish a race

To finish a race, a car has to be able to drive the race's distance. This means not draining its battery before having crossed the finish line. Implement the RaceTrack.tryFinishTrack() method that takes a NeedForSpeed instance as its parameter and returns true if the car can finish the race; otherwise, return false. To see if the car can finish the race, you should try to drive the car until either you reach the end of the track or the battery drains:

Also, note the first point in the hints for task 6:

Check if a remote control car can finish a race

  • Solving this is probably best done by repeatedly driving the car.
  • Remember that the car has a method to retrieve the distance it has driven.
  • Consider what to do when the battery has been drained before reaching the finish line.
manumafe98 commented 4 months ago

Hey @kahgoh thanks for opening an issue, you're right, we modified the reference resolution and built the analyzer so the students try to solve it without using a loop but forgot to change the instructions and hints, if you want to open a PR to fix this, go ahead!