Last active
December 15, 2015 19:16
-
-
Save HDBandit/49522d058c674f931f2d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// business logic | |
public static List<Car> filterCarsByBrandAndColor(List<Car> cars, String brand, String color) { | |
// we can reuse the method to filtering by brand | |
List<Car> filteredCarsByBrand = filterCarsByBrand(cars, brand); | |
ArrayList<Car> filteredCars = new ArrayList<Car>(); | |
for (Car car : cars) { | |
if (color.equals(car.getColor())) { | |
filteredCars.add(car); | |
} | |
} | |
return filteredCars; | |
} | |
... | |
// from your programm, you can call it from this way | |
List<Car> filteredCars = filterCarsByBrand(cars, "Ferrari", "red"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment