package de.diejungsvondertanke.tankstelle;
+import java.util.ArrayList;
+
/**
* Main Class
*/
public static void main(String[] args) {
}
+
+ /**
+ * Get an array of fuel stations which have a number of vending machines
+ * that is equal to {@code number_of_vending_machines}
+ *
+ * @param number_of_vending_machines Select all fuel stations with this number
+ * of vending machines
+ * @return an array of fuel stations (all of type {@link SmallFuelStation})
+ */
+ public static FuelStation[] getFuelStations(short number_of_vending_machines) {
+ ArrayList<FuelStation> result = new ArrayList<FuelStation>();
+ for (FuelStation fuelStation : fuelStations) {
+ if (fuelStation instanceof SmallFuelStation
+ && ((SmallFuelStation) fuelStation).getNumber_of_vending_machines() == number_of_vending_machines)
+ result.add(fuelStation);
+ }
+ return result.toArray(new FuelStation[0]); // Change to SmallFuelStation if required
+ }
+
+ /**
+ * Get an array of fuel stations which have an amount of square
+ * metres of retail space that is equal to {@code retail_space}
+ *
+ * @param retail_space Select all fuel stations with this amount of square
+ * metres of retail space
+ * @return an array of fuel stations (all of type {@link MediumFuelStation})
+ */
+ public static FuelStation[] getFuelStations(float retail_space) {
+ ArrayList<FuelStation> result = new ArrayList<FuelStation>();
+ for (FuelStation fuelStation : fuelStations) {
+ if (fuelStation instanceof MediumFuelStation
+ && ((MediumFuelStation) fuelStation).getRetail_space() == retail_space)
+ result.add(fuelStation);
+ }
+ return result.toArray(new FuelStation[0]); // Change to MediumFuelStation if required
+ }
+
+ /**
+ * Get an array of fuel stations whose integrated supermarket is run by
+ * {@code retail_space}
+ *
+ * @param supermarket_company Select all fuel stations with this company running
+ * the integrated supermarket
+ * @return an array of fuel stations (all of type {@link LargeFuelStation})
+ */
+ public static FuelStation[] getFuelStations(String supermarket_company) {
+ ArrayList<FuelStation> result = new ArrayList<FuelStation>();
+ for (FuelStation fuelStation : fuelStations) {
+ if (fuelStation instanceof LargeFuelStation
+ && ((LargeFuelStation) fuelStation).getSupermarket_company().equals(supermarket_company))
+ result.add(fuelStation);
+ }
+ return result.toArray(new FuelStation[0]); // Change to LargeFuelStation if required
+ }
}
\ No newline at end of file
*/
public class SmallFuelStation extends FuelStation {
/**
- * Number of drink vending machines
+ * Number of drink vending machines
*/
private short number_of_vending_machines;
super(number_of_employees, Size.SMALL, fuels);
this.number_of_vending_machines = number_of_vending_machines;
}
+
+ /**
+ * Getter method
+ *
+ * @return the number of drink vending machines this fuel station has
+ */
+ public short getNumber_of_vending_machines() {
+ return number_of_vending_machines;
+ }
}