Skip to content

Commit 1cae702

Browse files
authored
Change TestTrack.getRankedCars stub to take a list of cars, consistent with the unit tests (exercism#2337)
* Change TestTrack.getRankedCars stub to take a list of cars, consistent with the unit tests * Update additional getRankedCars functions
1 parent d944d6e commit 1cae702

3 files changed

Lines changed: 6 additions & 11 deletions

File tree

exercises/concept/remote-control-competition/.docs/instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ prc2.setNumberOfVictories(2);
5959
List<ProductionRemoteControlCar> unsortedCars = new ArrayList<>();
6060
unsortedCars.add(prc1);
6161
unsortedCars.add(prc2);
62-
List<ProductionRemoteControlCar> rankings = TestTrack.getRankedCars(prc1, prc2);
62+
List<ProductionRemoteControlCar> rankings = TestTrack.getRankedCars(unsortedCars);
6363
// => rankings.get(0) == prc2
6464
// => rankings.get(1) == prc1
6565
```

exercises/concept/remote-control-competition/.meta/src/reference/java/TestTrack.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@ public static void race(RemoteControlCar car) {
88
car.drive();
99
}
1010

11-
public static List<ProductionRemoteControlCar> getRankedCars(ProductionRemoteControlCar prc1,
12-
ProductionRemoteControlCar prc2) {
13-
List<ProductionRemoteControlCar> rankings = new ArrayList<>();
14-
rankings.add(prc1);
15-
rankings.add(prc1);
16-
Collections.sort(rankings);
17-
18-
return rankings;
11+
public static List<ProductionRemoteControlCar> getRankedCars(List<ProductionRemoteControlCar> cars) {
12+
List<ProductionRemoteControlCar> sorted = new ArrayList<>(cars);
13+
Collections.sort(sorted);
14+
return sorted;
1915
}
2016
}

exercises/concept/remote-control-competition/src/main/java/TestTrack.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ public static void race(RemoteControlCar car) {
66
throw new UnsupportedOperationException("Please implement the (static) TestTrack.race() method");
77
}
88

9-
public static List<ProductionRemoteControlCar> getRankedCars(ProductionRemoteControlCar prc1,
10-
ProductionRemoteControlCar prc2) {
9+
public static List<ProductionRemoteControlCar> getRankedCars(List<ProductionRemoteControlCar> cars) {
1110
throw new UnsupportedOperationException("Please implement the (static) TestTrack.getRankedCars() method");
1211
}
1312
}

0 commit comments

Comments
 (0)