package de.diejungsvondertanke.tankstelle;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
import java.util.ArrayList;
import de.diejungsvondertanke.tankstelle.error.NoSuchFuelTypeError;
}
return highestStation;
}
+
+ /**
+ * Check {@code pin} for the correct PIN number
+ *
+ * @param pin the PIN to check
+ * @return true, if the pin is correct, false otherwise
+ * @throws IOException if the configured file pin.txt was not found
+ */
+ public static boolean isPINCorrect(String pin) throws IOException {
+
+ BufferedReader bfro = new BufferedReader(new InputStreamReader(Main.class.getResourceAsStream("/pin.txt")));
+
+ if (bfro.readLine().trim().equals(pin.trim()))
+ return true;
+ else
+ return false;
+ }
+
+ /**
+ * This function will, for any number of employees, return an array of
+ * {@link FuelStation}s that can be opened with the staff given
+ *
+ * @param available_employees number of employees available
+ * @return All fuel stations that can reasonably be opened today
+ */
+ public static FuelStation[] getFuelStationListWhenUnderstaffed(short available_employees) {
+ ArrayList<FuelStation> result = new ArrayList<>();
+ FuelStation[] fuelStationsLocalCopy = FuelStation.sort(fuelStations);
+ for (FuelStation station : fuelStationsLocalCopy) {
+ if (Math.floorDiv(available_employees, station.getNumber_of_employees()) >= 1) {
+ available_employees -= station.getNumber_of_employees();
+ result.add(station);
+ }
+ }
+ return result.toArray(new FuelStation[0]);
+ }
}
\ No newline at end of file