Skip to content

Commit

Permalink
Update additional getRankedCars functions
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacG committed Aug 23, 2023
1 parent 52cfb26 commit b0fcfcf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ prc2.setNumberOfVictories(2);
List<ProductionRemoteControlCar> unsortedCars = new ArrayList<>();
unsortedCars.add(prc1);
unsortedCars.add(prc2);
List<ProductionRemoteControlCar> rankings = TestTrack.getRankedCars(prc1, prc2);
List<ProductionRemoteControlCar> rankings = TestTrack.getRankedCars(unsortedCars);
// => rankings.get(0) == prc2
// => rankings.get(1) == prc1
```
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ public static void race(RemoteControlCar car) {
car.drive();
}

public static List<ProductionRemoteControlCar> getRankedCars(ProductionRemoteControlCar prc1,
ProductionRemoteControlCar prc2) {
List<ProductionRemoteControlCar> rankings = new ArrayList<>();
rankings.add(prc1);
rankings.add(prc1);
Collections.sort(rankings);

return rankings;
public static List<ProductionRemoteControlCar> getRankedCars(List<ProductionRemoteControlCar> cars) {
List<ProductionRemoteControlCar> sorted = new ArrayList<>(cars);
Collections.sort(sorted);
return sorted;
}
}

0 comments on commit b0fcfcf

Please sign in to comment.