File tree Expand file tree Collapse file tree
exercises/concept/remote-control-competition Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ prc2.setNumberOfVictories(2);
5959List<ProductionRemoteControlCar > unsortedCars = new ArrayList<> ();
6060unsortedCars. add(prc1);
6161unsortedCars. 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```
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments