import de.diejungsvondertanke.tankstelle.core.FuelStation;
import de.diejungsvondertanke.tankstelle.core.FuelType;
-import de.diejungsvondertanke.tankstelle.error.NoSuchFuelTypeError;
+import de.diejungsvondertanke.tankstelle.exception.NoSuchFuelTypeException;
import javafx.fxml.FXML;
import javafx.scene.control.TextField;
} catch (NumberFormatException e) {
parentController.showError("Invalid number.");
- } catch (NoSuchFuelTypeError e) {
+ } catch (NoSuchFuelTypeException e) {
parentController.showError(e.getMessage());
}
}
import de.diejungsvondertanke.tankstelle.core.FuelStation;
import de.diejungsvondertanke.tankstelle.core.FuelType;
import de.diejungsvondertanke.tankstelle.core.Main;
-import de.diejungsvondertanke.tankstelle.error.FuelTypeException;
-import de.diejungsvondertanke.tankstelle.error.NoFuelTypeSelectedError;
-import de.diejungsvondertanke.tankstelle.error.NoSuchFuelTypeError;
+import de.diejungsvondertanke.tankstelle.exception.FuelTypeException;
+import de.diejungsvondertanke.tankstelle.exception.NoFuelTypeSelectedException;
+import de.diejungsvondertanke.tankstelle.exception.NoSuchFuelTypeException;
import javafx.fxml.FXML;
import javafx.scene.control.ListView;
import javafx.scene.control.SelectionMode;
try {
FuelStation fs = Main.getHighestAccumulatedValue();
parentController.appendOutput("Highest total value: " + parentController.getDisplayName(fs));
- } catch (NoSuchFuelTypeError e) {
+ } catch (NoSuchFuelTypeException e) {
parentController.showError(e.getMessage());
}
}
try {
total = Main.getTotalStockLevelOfFuel(type, stations);
parentController.appendOutput("Total for %s: %.2f L".formatted(type, total));
- } catch (NoFuelTypeSelectedError e) {
+ } catch (NoFuelTypeSelectedException e) {
parentController.showError(e.getMessage());
}
}
import de.diejungsvondertanke.tankstelle.core.FuelStation;
import de.diejungsvondertanke.tankstelle.core.FuelType;
import de.diejungsvondertanke.tankstelle.core.Main;
-import de.diejungsvondertanke.tankstelle.error.NoSuchFuelTypeError;
+import de.diejungsvondertanke.tankstelle.exception.NoSuchFuelTypeException;
import javafx.fxml.FXML;
/**
try {
station.getStored_amount(type);
sb.append(" - ").append(parentController.getDisplayName(station)).append("\n");
- } catch (NoSuchFuelTypeError ignore) {
+ } catch (NoSuchFuelTypeException ignore) {
}
}
import de.diejungsvondertanke.tankstelle.core.Fuel;
import de.diejungsvondertanke.tankstelle.core.FuelStation;
import de.diejungsvondertanke.tankstelle.core.FuelType;
-import de.diejungsvondertanke.tankstelle.error.NoSuchFuelTypeError;
+import de.diejungsvondertanke.tankstelle.exception.NoSuchFuelTypeException;
import javafx.fxml.FXML;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
this.parentController = parent;
}
- private int getCapacity(FuelStation station, FuelType type) throws NoSuchFuelTypeError {
+ private int getCapacity(FuelStation station, FuelType type) throws NoSuchFuelTypeException {
for (Fuel f : station.fuels) {
if (f.FUEL_TYPE == type)
return f.CAPACITY;
}
- throw new NoSuchFuelTypeError("This fuel station does not have this type of fuel");
+ throw new NoSuchFuelTypeException("This fuel station does not have this type of fuel");
}
/**
import java.util.ArrayList;
-import de.diejungsvondertanke.tankstelle.error.NoSuchFuelTypeError;
+import de.diejungsvondertanke.tankstelle.exception.NoSuchFuelTypeException;
/**
* Abstract class.
*
* @param type The {@link FuelType FuelType} to change
* @param new_amount The new fuel amount
- * @throws NoSuchFuelTypeError This Error is thrown on the attempt to choose a
- * fuel type from a fuel station
- * which the fuel station does not have
+ * @throws NoSuchFuelTypeException This Error is thrown on the attempt to choose
+ * a
+ * fuel type from a fuel station
+ * which the fuel station does not have
*
* @author Nils Göbbert
*/
- public void set_stored_amount(double new_amount, FuelType type) throws NoSuchFuelTypeError {
+ public void set_stored_amount(double new_amount, FuelType type) throws NoSuchFuelTypeException {
for (Fuel i : fuels) {
if (i.FUEL_TYPE == type) {
i.setStored_amount(new_amount);
return;
}
- throw new NoSuchFuelTypeError("This fuel station does not have fuel of the given type");
+ throw new NoSuchFuelTypeException("This fuel station does not have fuel of the given type");
}
}
*
* @param type The {@link FuelType FuelType} to change
* @param new_amount The amount of fuel that is added or subtracted
- * @throws NoSuchFuelTypeError This Error is thrown on the attempt to choose a
- * fuel type from a fuel station
- * which the fuel station does not have
+ * @throws NoSuchFuelTypeException This Error is thrown on the attempt to choose
+ * a
+ * fuel type from a fuel station
+ * which the fuel station does not have
*
* @author Nils Göbbert
*/
- public void add_stored_amount(double new_amount, FuelType type) throws NoSuchFuelTypeError, ArithmeticException {
+ public void add_stored_amount(double new_amount, FuelType type)
+ throws NoSuchFuelTypeException, ArithmeticException {
for (Fuel i : fuels) {
if (i.FUEL_TYPE == type) {
if (new_amount + i.getStored_amount() < 0) {
return;
}
}
- throw new NoSuchFuelTypeError("This fuel station does not have fuel of the given type");
+ throw new NoSuchFuelTypeException("This fuel station does not have fuel of the given type");
}
/**
*
* @param fuel_type The {@link FuelType FuelTypes} to change
* @param price The new price per litre
- * @throws NoSuchFuelTypeError This Error is thrown on the attempt to choose a
- * fuel type from a fuel station
- * which the fuel station does not have
+ * @throws NoSuchFuelTypeException This Error is thrown on the attempt to choose
+ * a
+ * fuel type from a fuel station
+ * which the fuel station does not have
*
* @author Robin Cheney
*/
- public void set_price(FuelType fuel_type, float price) throws NoSuchFuelTypeError {
+ public void set_price(FuelType fuel_type, float price) throws NoSuchFuelTypeException {
for (Fuel i : fuels) {
if (i.FUEL_TYPE == fuel_type) {
i.setPrice(price);
return;
}
}
- throw new NoSuchFuelTypeError("This fuel station does not have fuel of the given type");
+ throw new NoSuchFuelTypeException("This fuel station does not have fuel of the given type");
}
/**
*
* @param fuel_type The {@link FuelType FuelType} to get
* @return The price for a specific type of fuel for this fuel station
- * @throws NoSuchFuelTypeError This Error is thrown on the attempt to choose a
- * fuel type from a fuel station
- * which the fuel station does not have
+ * @throws NoSuchFuelTypeException This Error is thrown on the attempt to choose
+ * a
+ * fuel type from a fuel station
+ * which the fuel station does not have
*
* @author Robin Cheney
*/
- public float get_price(FuelType fuel_type) throws NoSuchFuelTypeError {
+ public float get_price(FuelType fuel_type) throws NoSuchFuelTypeException {
for (Fuel i : fuels) {
if (i.FUEL_TYPE == fuel_type) {
return i.getPrice();
}
}
- throw new NoSuchFuelTypeError("This fuel station does not have fuel of the given type");
+ throw new NoSuchFuelTypeException("This fuel station does not have fuel of the given type");
}
/**
*
* @param fuel_type The {@link FuelType FuelType} to get
* @return The fuel amount for a specific type of fuel for this fuel station
- * @throws NoSuchFuelTypeError This Error is thrown on the attempt to choose a
- * fuel type from a fuel station
- * which the fuel station does not have
+ * @throws NoSuchFuelTypeException This Error is thrown on the attempt to choose
+ * a
+ * fuel type from a fuel station
+ * which the fuel station does not have
*
* @author Nils Göbbert
*/
- public double getStored_amount(FuelType fuel_type) throws NoSuchFuelTypeError {
+ public double getStored_amount(FuelType fuel_type) throws NoSuchFuelTypeException {
for (Fuel i : fuels) {
if (i.FUEL_TYPE == fuel_type) {
return i.getStored_amount();
}
}
- throw new NoSuchFuelTypeError("This fuel station does not have fuel of the given type");
+ throw new NoSuchFuelTypeException("This fuel station does not have fuel of the given type");
}
/**
import java.util.ArrayList;
import java.util.Arrays;
-import de.diejungsvondertanke.tankstelle.error.NoFuelTypeSelectedError;
-import de.diejungsvondertanke.tankstelle.error.NoSuchFuelTypeError;
+import de.diejungsvondertanke.tankstelle.exception.NoFuelTypeSelectedException;
+import de.diejungsvondertanke.tankstelle.exception.NoSuchFuelTypeException;
/**
* Main Class
* @param fuelType Select the type of fuel
*
* @return a FuelStation (all of type {@link FuelStation})
- * @throws NoSuchFuelTypeError This Error is thrown on the attempt to choose a
- * fuel type from a fuel station which the fuel
- * station does not have
+ * @throws NoSuchFuelTypeException This Error is thrown on the attempt to choose
+ * a
+ * fuel type from a fuel station which the fuel
+ * station does not have
*
* @author Nils Göbbert
*/
- public static FuelStation getHighestPrice(FuelType fuelType) throws NoSuchFuelTypeError, NoFuelTypeSelectedError {
+ public static FuelStation getHighestPrice(FuelType fuelType)
+ throws NoSuchFuelTypeException, NoFuelTypeSelectedException {
FuelStation highestStation = null;
float highestPrice = Float.NEGATIVE_INFINITY;
if (fuelType == null)
- throw new NoFuelTypeSelectedError();
+ throw new NoFuelTypeSelectedException();
for (FuelStation fuelStation : fuelStations) {
try {
highestPrice = price;
highestStation = fuelStation;
}
- } catch (NoSuchFuelTypeError e) {
+ } catch (NoSuchFuelTypeException e) {
}
}
if (highestStation == null) {
- throw new NoSuchFuelTypeError("No fuel station with " + fuelType + " found");
+ throw new NoSuchFuelTypeException("No fuel station with " + fuelType + " found");
}
return highestStation;
}
*
*
* @return a FuelStation (all of type {@link FuelStation})
- * @throws NoSuchFuelTypeError This Error is thrown on the attempt to choose a
- * fuel type from a fuel station which the fuel
- * station does not have
+ * @throws NoSuchFuelTypeException This Error is thrown on the attempt to choose
+ * a
+ * fuel type from a fuel station which the fuel
+ * station does not have
*
* @author Nils Göbbert
*/
- public static FuelStation getHighestAccumulatedValue() throws NoSuchFuelTypeError {
+ public static FuelStation getHighestAccumulatedValue() throws NoSuchFuelTypeException {
float highestValue = fuelStations.get(0).get_cumulative_retail_price();
FuelStation highestStation = fuelStations.get(0);
for (FuelStation fuelStation : fuelStations) {
* @param fuelType Select the type of fuel
*
* @return a FuelStation (all of type {@link FuelStation})
- * @throws NoSuchFuelTypeError This Error is thrown on the attempt to choose a
- * fuel type from a fuel station which the fuel
- * station does not have
+ * @throws NoSuchFuelTypeException This Error is thrown on the attempt to choose
+ * a
+ * fuel type from a fuel station which the fuel
+ * station does not have
*
* @author Nils Göbbert
*/
public static FuelStation getHighestStoredAmount(FuelType fuelType)
- throws NoSuchFuelTypeError, NoFuelTypeSelectedError {
+ throws NoSuchFuelTypeException, NoFuelTypeSelectedException {
FuelStation highestStation = null;
double highestAmount = Double.NEGATIVE_INFINITY;
if (fuelType == null)
- throw new NoFuelTypeSelectedError();
+ throw new NoFuelTypeSelectedException();
for (FuelStation fuelStation : fuelStations) {
try {
double amount = fuelStation.getStored_amount(fuelType);
highestAmount = amount;
highestStation = fuelStation;
}
- } catch (NoSuchFuelTypeError e) {
+ } catch (NoSuchFuelTypeException e) {
}
}
if (highestStation == null) {
- throw new NoSuchFuelTypeError("No fuel station with " + fuelType + " found");
+ throw new NoSuchFuelTypeException("No fuel station with " + fuelType + " found");
}
return highestStation;
}
* @param fuelType Select the type of fuel
*
* @return a FuelStation (all of type {@link FuelStation})
- * @throws NoSuchFuelTypeError This Error is thrown on the attempt to choose a
- * fuel type from a fuel station which the fuel
- * station does not have
+ * @throws NoSuchFuelTypeException This Error is thrown on the attempt to choose
+ * a
+ * fuel type from a fuel station which the fuel
+ * station does not have
*
* @author Nils Göbbert
*/
public static FuelStation getLowestStoredAmount(FuelType fuelType)
- throws NoSuchFuelTypeError, NoFuelTypeSelectedError {
+ throws NoSuchFuelTypeException, NoFuelTypeSelectedException {
FuelStation lowestStation = null;
double lowestAmount = Double.POSITIVE_INFINITY;
if (fuelType == null)
- throw new NoFuelTypeSelectedError();
+ throw new NoFuelTypeSelectedException();
for (FuelStation fuelStation : fuelStations) {
try {
lowestAmount = amount;
lowestStation = fuelStation;
}
- } catch (NoSuchFuelTypeError e) {
+ } catch (NoSuchFuelTypeException e) {
}
}
if (lowestStation == null) {
- throw new NoSuchFuelTypeError("No fuel station with " + fuelType + " found");
+ throw new NoSuchFuelTypeException("No fuel station with " + fuelType + " found");
}
return lowestStation;
}
* @author Leander Schnurrer
*/
public static float getTotalStockLevelOfFuel(FuelType fuelType, FuelStation[] fuelStations)
- throws NoFuelTypeSelectedError {
+ throws NoFuelTypeSelectedException {
float sum = 0f;
if (fuelType == null)
- throw new NoFuelTypeSelectedError();
+ throw new NoFuelTypeSelectedException();
for (FuelStation fuelStation : fuelStations) {
for (Fuel fuel : fuelStation.fuels) {
if (fuel.FUEL_TYPE == fuelType) {
+++ /dev/null
-package de.diejungsvondertanke.tankstelle.error;
-
-/**
- * This Error is thrown on the attempt to get the selected fuel type whenever
- * there is none selected
- *
- * @author Robin Cheney
- */
-public class NoFuelTypeSelectedError extends FuelTypeException {
- /**
- * Throws a {@link NoFuelTypeSelectedError}
- *
- * @param message Message to throw with this error
- *
- * @author Robin Cheney
- */
- public NoFuelTypeSelectedError(String message) {
- super(message);
- }
-
- /**
- * Throws a {@link NoFuelTypeSelectedError}
- *
- * @author Robin Cheney
- */
- public NoFuelTypeSelectedError() {
- super("No fuel type selected");
- }
-}
-package de.diejungsvondertanke.tankstelle.error;
+package de.diejungsvondertanke.tankstelle.exception;
import de.diejungsvondertanke.tankstelle.core.FuelType;
--- /dev/null
+package de.diejungsvondertanke.tankstelle.exception;
+
+/**
+ * This Exception is thrown on the attempt to get the selected fuel type
+ * whenever
+ * there is none selected
+ *
+ * @author Robin Cheney
+ */
+public class NoFuelTypeSelectedException extends FuelTypeException {
+ /**
+ * Throws a {@link NoFuelTypeSelectedException}
+ *
+ * @param message Message to throw with this Exception
+ *
+ * @author Robin Cheney
+ */
+ public NoFuelTypeSelectedException(String message) {
+ super(message);
+ }
+
+ /**
+ * Throws a {@link NoFuelTypeSelectedException}
+ *
+ * @author Robin Cheney
+ */
+ public NoFuelTypeSelectedException() {
+ super("No fuel type selected");
+ }
+}
-package de.diejungsvondertanke.tankstelle.error;
+package de.diejungsvondertanke.tankstelle.exception;
/**
* This Error is thrown on the attempt to choose a fuel type from a fuel station
*
* @author Robin Cheney
*/
-public class NoSuchFuelTypeError extends FuelTypeException {
+public class NoSuchFuelTypeException extends FuelTypeException {
/**
- * Throws a {@link NoSuchFuelTypeError}
+ * Throws a {@link NoSuchFuelTypeException}
*
* @param message Message to throw with this error
*
* @author Robin Cheney
*/
- public NoSuchFuelTypeError(String message) {
+ public NoSuchFuelTypeException(String message) {
super(message);
}
/**
- * Throws a {@link NoSuchFuelTypeError}
+ * Throws a {@link NoSuchFuelTypeException}
*
* @author Robin Cheney
*/
- public NoSuchFuelTypeError() {
+ public NoSuchFuelTypeException() {
super("This fuel station does not have this type of fuel");
}
}