* @author Robin Cheney
* @author Nils Göbbert
* @author Leander Schnurrer
+ * @author Jef Bettenworth
*/
public class Main {
/**
return sum;
}
+ /**
+ * Returns all fuel stations that offer a specific type of fuel. The method
+ * iterates over all existing fuel stations and checks whethertheir internal
+ * fuel array (fuels[]) contains a Fuel object whose{@code FUEL_TYPE} matches
+ * the given {@code wantedType}. Every matching fuel station is added to the
+ * result and returned as an ArrayList.
+ *
+ * @param wantedType The fuel type to filter for.
+ *
+ * @return An ArrayList of all fuel stations that offer the specified fuel type.
+ *
+ * @author Jef Bettenworth
+ */
+ public static ArrayList<FuelStation> getFuelStationsByFuelType(FuelType wantedType) {
+ ArrayList<FuelStation> result = new ArrayList<>();
+
+ for (FuelStation station : fuelStations) {
+ for (Fuel fuel : station.fuels) {
+ if (fuel.FUEL_TYPE == wantedType) {
+ result.add(station);
+ break; // keine Duplikate
+ }
+ }
+ }
+
+ return result;
+ }
+
}
\ No newline at end of file