*/
static ArrayList<FuelStation> fuelStations = new ArrayList<FuelStation>(Arrays.asList(initialFuelStations));
-
/**
* Main method
*
* @author Nils Göbbert
*/
public static FuelStation getHighestPrice(FuelType fuelType) throws NoSuchFuelTypeError {
- float highestPrice = fuelStations.toArray(new FuelStation[0])[0].get_price(fuelType);
- FuelStation highestStation = fuelStations.toArray(new FuelStation[0])[0];
+ float highestPrice = fuelStations.get(0).get_price(fuelType);
+ FuelStation highestStation = fuelStations.get(0);
for (FuelStation fuelStation : fuelStations) {
if (fuelStation.get_price(fuelType) > highestPrice) {
highestPrice = fuelStation.get_price(fuelType);
* @author Nils Göbbert
*/
public static FuelStation getHighestAccumulatedValue() throws NoSuchFuelTypeError {
- float highestValue = fuelStations.toArray(new FuelStation[0])[0].get_cumulative_retail_price();
- FuelStation highestStation = fuelStations.toArray(new FuelStation[0])[0];
+ float highestValue = fuelStations.get(0).get_cumulative_retail_price();
+ FuelStation highestStation = fuelStations.get(0);
for (FuelStation fuelStation : fuelStations) {
if (fuelStation.get_cumulative_retail_price() > highestValue) {
highestValue = fuelStation.get_cumulative_retail_price();
* @author Nils Göbbert
*/
public static FuelStation getHighestStoredAmount(FuelType fuelType) throws NoSuchFuelTypeError {
- float highestAmount = fuelStations.toArray(new FuelStation[0])[0].getStored_amount(fuelType);
- FuelStation highestStation = fuelStations.toArray(new FuelStation[0])[0];
+ float highestAmount = fuelStations.get(0).getStored_amount(fuelType);
+ FuelStation highestStation = fuelStations.get(0);
for (FuelStation fuelStation : fuelStations) {
if (fuelStation.getStored_amount(fuelType) > highestAmount) {
highestAmount = fuelStation.getStored_amount(fuelType);
* @author Nils Göbbert
*/
public static FuelStation getLowestStoredAmount(FuelType fuelType) throws NoSuchFuelTypeError {
- float lowestAmount = fuelStations.toArray(new FuelStation[0])[0].getStored_amount(fuelType);
- FuelStation lowestStation = fuelStations.toArray(new FuelStation[0])[0];
+ float lowestAmount = fuelStations.get(0).getStored_amount(fuelType);
+ FuelStation lowestStation = fuelStations.get(0);
for (FuelStation fuelStation : fuelStations) {
if (fuelStation.getStored_amount(fuelType) > lowestAmount) {
lowestAmount = fuelStation.getStored_amount(fuelType);
return sum;
}
-
/**
* Add new large fuel stations
+ *
* @param supermarket_company add the special attribut for large fuel stations
*
* @author Leander Schnurrer
*/
- public static void addNewFuelstation(String supermarket_company){
- while(supermarket_company.isEmpty()){
- // Show error in UI
+ public static void addNewFuelstation(String supermarket_company) {
+ while (supermarket_company.isEmpty()) {
+ // TODO: Show error in UI
}
fuelStations.add(new LargeFuelStation(supermarket_company));
}
/**
* Add new medium fuel stations
+ *
* @param retail_space add the special attribut for medium fuel stations
*
* @author Leander Schnurrer
*/
- public static void addNewFuelstation(float retail_space){
- while(retail_space <= 0) {
- // Show error in UI
+ public static void addNewFuelstation(float retail_space) {
+ while (retail_space <= 0) {
+ // TODO: Show error in UI
}
fuelStations.add(new MediumFuelStation(retail_space));
}
/**
* Add new small fuel stations
- * @param number_of_vending_machines add the special attribut for small fuel stations
+ *
+ * @param number_of_vending_machines add the special attribut for small fuel
+ * stations
*
* @author Leander Schnurrer
*/
- public static void addNewFuelstation(short number_of_vending_machines){
- while(number_of_vending_machines <= 0) {
- // Show error in UI
+ public static void addNewFuelstation(short number_of_vending_machines) {
+ while (number_of_vending_machines <= 0) {
+ // TODO: Show error in UI
}
fuelStations.add(new SmallFuelStation(number_of_vending_machines));
}
-
/**
- * Determine the total stock levels of selected petrol stations for a given type of fuel
+ * Determine the total stock levels of selected petrol stations for a given type
+ * of fuel
*
- * @param fuelType select the fuel type
- * @param FuelStations select the fuel stations
+ * @param fuelType select the fuel type
+ * @param FuelStations select the fuel stations
*
- * @return the sum of stock levels of the specific fuel type from the selected fuel stations
+ * @return the sum of stock levels of the specific fuel type from the selected
+ * fuel stations
*
* @author Leander Schnurrer
*/
public static float getTotalStockLevelOfFuel(FuelType fuelType, FuelStation[] FuelStations) {
float sum = 0f;
- for(FuelStation fuelStation : FuelStations){
- for(Fuel fuel : fuelStation.fuels){
- if(fuel.getFuelType() == fuelType){
+ for (FuelStation fuelStation : FuelStations) {
+ for (Fuel fuel : fuelStation.fuels) {
+ if (fuel.getFuelType() == fuelType) {
sum += fuel.getStored_amount();
break;
}
return sum;
}
-
}
\ No newline at end of file