From 2a9c1dd58b14cd789b7da816428216e9747c5d81 Mon Sep 17 00:00:00 2001 From: Robin Cheney Date: Sun, 16 Nov 2025 11:33:02 +0100 Subject: [PATCH] added @author declarations for every class and method --- .../diejungsvondertanke/tankstelle/Fuel.java | 20 ++++++ .../tankstelle/FuelStation.java | 62 ++++++++++++++++++- .../tankstelle/FuelType.java | 2 + .../tankstelle/LargeFuelStation.java | 6 ++ .../diejungsvondertanke/tankstelle/Main.java | 32 +++++++++- .../tankstelle/MediumFuelStation.java | 6 ++ .../diejungsvondertanke/tankstelle/Size.java | 2 + .../tankstelle/SmallFuelStation.java | 6 ++ .../tankstelle/error/NoSuchFuelTypeError.java | 6 ++ 9 files changed, 138 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/diejungsvondertanke/tankstelle/Fuel.java b/src/main/java/de/diejungsvondertanke/tankstelle/Fuel.java index c7e60e0..2a13627 100644 --- a/src/main/java/de/diejungsvondertanke/tankstelle/Fuel.java +++ b/src/main/java/de/diejungsvondertanke/tankstelle/Fuel.java @@ -3,6 +3,8 @@ package de.diejungsvondertanke.tankstelle; /** * A fuel object. Contains fuel type, price per litre, stored fuel amount and * storage capacity for this fuel + * + * @author Robin Cheney */ public class Fuel { /** @@ -33,6 +35,8 @@ public class Fuel { * @param stored_amount Currently stored amount of fuel in L * @param capacity Maximum fuel storage capacity in L * @param price Retail price in € / L + * + * @author Robin Cheney */ public Fuel(FuelType fuel_type, float stored_amount, float price, int capacity) { this.FUEL_TYPE = fuel_type; @@ -45,6 +49,10 @@ public class Fuel { * Getter method * * @return {@link FuelType FuelType} of this {@link Fuel Fuel} + * + * @deprecated + * + * @author Robin Cheney */ public FuelType getFuelType() { return FUEL_TYPE; @@ -54,6 +62,8 @@ public class Fuel { * Getter method * * @return {@link #stored_amount stored amount of fuel} + * + * @author Robin Cheney */ public float getStored_amount() { return stored_amount; @@ -63,6 +73,8 @@ public class Fuel { * Set new stored amount of fuel * * @param stored_amount New stored amount of fuel + * + * @author Robin Cheney */ public void setStored_amount(float stored_amount) { this.stored_amount = stored_amount; @@ -72,6 +84,10 @@ public class Fuel { * Getter method * * @return {@link #CAPACITY Maximum fuel capacity} + * + * @deprecated + * + * @author Robin Cheney */ public int getCapacity() { return CAPACITY; @@ -81,6 +97,8 @@ public class Fuel { * Getter method * * @return {@link #price price in € / L fuel} + * + * @author Robin Cheney */ public float getPrice() { return price; @@ -90,6 +108,8 @@ public class Fuel { * Set new price in € / L fuel * * @param price New price in € / L fuel + * + * @author Robin Cheney */ public void setPrice(float price) { this.price = price; diff --git a/src/main/java/de/diejungsvondertanke/tankstelle/FuelStation.java b/src/main/java/de/diejungsvondertanke/tankstelle/FuelStation.java index 8b7658f..c2c5fe3 100644 --- a/src/main/java/de/diejungsvondertanke/tankstelle/FuelStation.java +++ b/src/main/java/de/diejungsvondertanke/tankstelle/FuelStation.java @@ -11,6 +11,9 @@ import de.diejungsvondertanke.tankstelle.error.NoSuchFuelTypeError; * @see LargeFuelStation * @see MediumFuelStation * @see SmallFuelStation + * + * @author Robin Cheney + * @author Nils Göbbert */ abstract class FuelStation { /** @@ -39,6 +42,8 @@ abstract class FuelStation { * @see LargeFuelStation * @see MediumFuelStation * @see SmallFuelStation + * + * @author Robin Cheney */ protected FuelStation(byte number_of_employees, Size size, Fuel[] fuels) { this.number_of_employees = number_of_employees; @@ -54,6 +59,8 @@ abstract class 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 + * + * @author Nils Göbbert */ public void set_stored_amount(float new_amount, FuelType type) throws NoSuchFuelTypeError { for (Fuel i : fuels) { @@ -74,12 +81,14 @@ abstract class 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 + * + * @author Nils Göbbert */ public void add_stored_amount(float new_amount, FuelType type) throws NoSuchFuelTypeError, ArithmeticException { for (Fuel i : fuels) { if (i.FUEL_TYPE == type) { if (new_amount + i.getStored_amount() < 0) { - throw new ArithmeticException("Fuel amound can't be negativ"); + throw new ArithmeticException("Fuel amount can't be negative"); } i.setStored_amount(new_amount + i.getStored_amount()); return; @@ -96,6 +105,8 @@ abstract class 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 + * + * @author Robin Cheney */ public void set_price(FuelType fuel_type, float price) throws NoSuchFuelTypeError { for (Fuel i : fuels) { @@ -115,6 +126,8 @@ abstract class 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 + * + * @author Robin Cheney */ public float get_price(FuelType fuel_type) throws NoSuchFuelTypeError { for (Fuel i : fuels) { @@ -132,6 +145,8 @@ abstract class FuelStation { * current price(s) * * @return the income in € + * + * @author Robin Cheney */ public float get_cumulative_retail_price() { float result = 0; @@ -145,6 +160,8 @@ abstract class FuelStation { * Getter method * * @return {@link #number_of_employees} + * + * @author Robin Cheney */ public byte getNumber_of_employees() { return number_of_employees; @@ -155,8 +172,47 @@ abstract class FuelStation { * * @param stations Array of {@link FuelStation}s * @return an ordered array of {@link FuelStation}s + * + * @author Robin Cheney + */ + public static FuelStation[] sortDescending(FuelStation[] stations) { + ArrayList result = new ArrayList<>(); + ArrayList large = new ArrayList<>(); + ArrayList medium = new ArrayList<>(); + ArrayList small = new ArrayList<>(); + + for (FuelStation station : stations) { + switch (station.size) { + case SMALL: + small.add(station); + break; + case MEDIUM: + medium.add(station); + break; + case LARGE: + large.add(station); + break; + default: + System.out.println("Unknown FuelStation size for object: " + station.toString()); + break; + } + + } + result.addAll(large); + result.addAll(medium); + result.addAll(small); + return result.toArray(new FuelStation[0]); + } + + /** + * Sort the fuel stations by size in a ascending order (smallest stations first) + * + * @param stations Array of {@link FuelStation}s + * @return an ordered array of {@link FuelStation}s + * + * @author Robin Cheney */ - public static FuelStation[] sort(FuelStation[] stations) { + public static FuelStation[] sortAscending(FuelStation[] stations) { ArrayList result = new ArrayList<>(); ArrayList large = new ArrayList<>(); ArrayList medium = new ArrayList<>(); @@ -193,6 +249,8 @@ abstract class 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 + * + * @author Nils Göbbert */ public float getStored_amount(FuelType fuel_type) throws NoSuchFuelTypeError { for (Fuel i : fuels) { diff --git a/src/main/java/de/diejungsvondertanke/tankstelle/FuelType.java b/src/main/java/de/diejungsvondertanke/tankstelle/FuelType.java index 5a01f84..24c36b0 100644 --- a/src/main/java/de/diejungsvondertanke/tankstelle/FuelType.java +++ b/src/main/java/de/diejungsvondertanke/tankstelle/FuelType.java @@ -2,6 +2,8 @@ package de.diejungsvondertanke.tankstelle; /** * Possible {@link Fuel fuel} types + * + * @author Robin Cheney */ public enum FuelType { /** diff --git a/src/main/java/de/diejungsvondertanke/tankstelle/LargeFuelStation.java b/src/main/java/de/diejungsvondertanke/tankstelle/LargeFuelStation.java index 05aba13..b2a95c3 100644 --- a/src/main/java/de/diejungsvondertanke/tankstelle/LargeFuelStation.java +++ b/src/main/java/de/diejungsvondertanke/tankstelle/LargeFuelStation.java @@ -2,6 +2,8 @@ package de.diejungsvondertanke.tankstelle; /** * Large {@link FuelStation fuel station} + * + * @author Robin Cheney */ public class LargeFuelStation extends FuelStation { /** @@ -18,6 +20,8 @@ public class LargeFuelStation extends FuelStation { * * @param supermarket_company The company managing the integrated supermarket * @see #supermarket_company + * + * @author Robin Cheney */ public LargeFuelStation(String supermarket_company) { super(NUMBER_OF_EMPLOYEES, Size.LARGE, new Fuel[] { new Fuel(FuelType.SUPER, 8000f, 1.7f, 16000), @@ -32,6 +36,8 @@ public class LargeFuelStation extends FuelStation { * Getter method * * @return the name of the company running the integrated supermarket + * + * @author Robin Cheney */ public String getSupermarket_company() { return supermarket_company; diff --git a/src/main/java/de/diejungsvondertanke/tankstelle/Main.java b/src/main/java/de/diejungsvondertanke/tankstelle/Main.java index 13a5719..729ba11 100644 --- a/src/main/java/de/diejungsvondertanke/tankstelle/Main.java +++ b/src/main/java/de/diejungsvondertanke/tankstelle/Main.java @@ -9,6 +9,9 @@ import de.diejungsvondertanke.tankstelle.error.NoSuchFuelTypeError; /** * Main Class + * + * @author Robin Cheney + * @author Nils Göbbert */ public class Main { /** @@ -19,6 +22,11 @@ public class Main { new LargeFuelStation("PlatzhalterFirma1"), new LargeFuelStation("PlatzhalterFirma2"), new LargeFuelStation("PlatzhalterFirma3") }; + /** + * Main method + * + * @param args Program arguments (not in use) + */ public static void main(String[] args) { } @@ -29,6 +37,8 @@ public class Main { * @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}) + * + * @author Robin Cheney */ public static FuelStation[] getFuelStations(short number_of_vending_machines) { ArrayList result = new ArrayList(); @@ -47,6 +57,8 @@ public class Main { * @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}) + * + * @author Robin Cheney */ public static FuelStation[] getFuelStations(float retail_space) { ArrayList result = new ArrayList(); @@ -65,6 +77,8 @@ public class Main { * @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}) + * + * @author Robin Cheney */ public static FuelStation[] getFuelStations(String supermarket_company) { ArrayList result = new ArrayList(); @@ -86,6 +100,8 @@ public class Main { * @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 + * + * @author Nils Göbbert */ public static FuelStation getHighestPrice(FuelType fuelType) throws NoSuchFuelTypeError { float highestPrice = fuelStations[0].get_price(fuelType); @@ -107,6 +123,8 @@ public class Main { * @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 + * + * @author Nils Göbbert */ public static FuelStation getHighestAccumulatedValue() throws NoSuchFuelTypeError { float highestValue = fuelStations[0].get_cumulative_retail_price(); @@ -130,6 +148,8 @@ public class Main { * @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 + * + * @author Nils Göbbert */ public static FuelStation getHighestStoredAmount(FuelType fuelType) throws NoSuchFuelTypeError { float highestAmount = fuelStations[0].getStored_amount(fuelType); @@ -153,6 +173,8 @@ public class Main { * @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 + * + * @author Nils Göbbert */ public static FuelStation getLowestStoredAmount(FuelType fuelType) throws NoSuchFuelTypeError { float lowestAmount = fuelStations[0].getStored_amount(fuelType); @@ -173,6 +195,8 @@ public class Main { * @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 + * + * @author Robin Cheney */ public static boolean isPINCorrect(String pin) throws IOException { @@ -189,11 +213,13 @@ public class Main { * {@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 + * @return All fuel stations that can reasonably be opened + * + * @author Robin Cheney */ public static FuelStation[] getFuelStationListWhenUnderstaffed(short available_employees) { ArrayList result = new ArrayList<>(); - FuelStation[] fuelStationsLocalCopy = FuelStation.sort(fuelStations); + FuelStation[] fuelStationsLocalCopy = FuelStation.sortDescending(fuelStations); for (FuelStation station : fuelStationsLocalCopy) { if (Math.floorDiv(available_employees, station.getNumber_of_employees()) >= 1) { available_employees -= station.getNumber_of_employees(); @@ -208,6 +234,8 @@ public class Main { * {@link FuelStation fuel station}s * * @return total staff count + * + * @author Robin Cheney */ public static int getTotalNumberOfEmployees() { int sum = 0; diff --git a/src/main/java/de/diejungsvondertanke/tankstelle/MediumFuelStation.java b/src/main/java/de/diejungsvondertanke/tankstelle/MediumFuelStation.java index bbabcfa..ff6636f 100644 --- a/src/main/java/de/diejungsvondertanke/tankstelle/MediumFuelStation.java +++ b/src/main/java/de/diejungsvondertanke/tankstelle/MediumFuelStation.java @@ -2,6 +2,8 @@ package de.diejungsvondertanke.tankstelle; /** * Medium {@link FuelStation fuel station} + * + * @author Robin Cheney */ public class MediumFuelStation extends FuelStation { /** @@ -18,6 +20,8 @@ public class MediumFuelStation extends FuelStation { * * @param retail_space m² of retail space * @see #retail_space retail_space + * + * @author Robin Cheney */ public MediumFuelStation(float retail_space) { super(NUMBER_OF_EMPLOYEES, Size.MEDIUM, new Fuel[] { new Fuel(FuelType.SUPER, 6000f, 1.7f, 12000), @@ -31,6 +35,8 @@ public class MediumFuelStation extends FuelStation { * Getter method * * @return retail space in m² + * + * @author Robin Cheney */ public float getRetail_space() { return retail_space; diff --git a/src/main/java/de/diejungsvondertanke/tankstelle/Size.java b/src/main/java/de/diejungsvondertanke/tankstelle/Size.java index 958627b..b406081 100644 --- a/src/main/java/de/diejungsvondertanke/tankstelle/Size.java +++ b/src/main/java/de/diejungsvondertanke/tankstelle/Size.java @@ -9,6 +9,8 @@ package de.diejungsvondertanke.tankstelle; * @see LargeFuelStation * @see MediumFuelStation * @see SmallFuelStation + * + * @author Robin Cheney */ public enum Size { /** diff --git a/src/main/java/de/diejungsvondertanke/tankstelle/SmallFuelStation.java b/src/main/java/de/diejungsvondertanke/tankstelle/SmallFuelStation.java index 6f660b6..e5f1e24 100644 --- a/src/main/java/de/diejungsvondertanke/tankstelle/SmallFuelStation.java +++ b/src/main/java/de/diejungsvondertanke/tankstelle/SmallFuelStation.java @@ -2,6 +2,8 @@ package de.diejungsvondertanke.tankstelle; /** * Small {@link FuelStation fuel station} + * + * @author Robin Cheney */ public class SmallFuelStation extends FuelStation { /** @@ -19,6 +21,8 @@ public class SmallFuelStation extends FuelStation { * * @param number_of_vending_machines Number of drink vending machines * @see #number_of_vending_machines + * + * @author Robin Cheney */ public SmallFuelStation(short number_of_vending_machines) { super(NUMBER_OF_EMPLOYEES, Size.SMALL, new Fuel[] { new Fuel(FuelType.SUPER, 4000f, 1.68f, 8000), @@ -30,6 +34,8 @@ public class SmallFuelStation extends FuelStation { * Getter method * * @return the number of drink vending machines this fuel station has + * + * @author Robin Cheney */ public short getNumber_of_vending_machines() { return number_of_vending_machines; diff --git a/src/main/java/de/diejungsvondertanke/tankstelle/error/NoSuchFuelTypeError.java b/src/main/java/de/diejungsvondertanke/tankstelle/error/NoSuchFuelTypeError.java index 1ce5b47..8c8851e 100644 --- a/src/main/java/de/diejungsvondertanke/tankstelle/error/NoSuchFuelTypeError.java +++ b/src/main/java/de/diejungsvondertanke/tankstelle/error/NoSuchFuelTypeError.java @@ -3,12 +3,16 @@ package de.diejungsvondertanke.tankstelle.error; /** * 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 class NoSuchFuelTypeError extends Exception { /** * Throws a {@link NoSuchFuelTypeError} * * @param message Message to throw with this error + * + * @author Robin Cheney */ public NoSuchFuelTypeError(String message) { super(message); @@ -16,6 +20,8 @@ public class NoSuchFuelTypeError extends Exception { /** * Throws a {@link NoSuchFuelTypeError} + * + * @author Robin Cheney */ public NoSuchFuelTypeError() { super(); -- 2.43.0