]> Git Server - tankstelle.git/commitdiff
added @author declarations for every class and method
authorRobin Cheney <cheneyr@eternal.ddnss.de>
Sun, 16 Nov 2025 10:33:02 +0000 (11:33 +0100)
committerRobin Cheney <cheneyr@eternal.ddnss.de>
Sun, 16 Nov 2025 10:33:02 +0000 (11:33 +0100)
src/main/java/de/diejungsvondertanke/tankstelle/Fuel.java
src/main/java/de/diejungsvondertanke/tankstelle/FuelStation.java
src/main/java/de/diejungsvondertanke/tankstelle/FuelType.java
src/main/java/de/diejungsvondertanke/tankstelle/LargeFuelStation.java
src/main/java/de/diejungsvondertanke/tankstelle/Main.java
src/main/java/de/diejungsvondertanke/tankstelle/MediumFuelStation.java
src/main/java/de/diejungsvondertanke/tankstelle/Size.java
src/main/java/de/diejungsvondertanke/tankstelle/SmallFuelStation.java
src/main/java/de/diejungsvondertanke/tankstelle/error/NoSuchFuelTypeError.java

index c7e60e011e77bd23987098a09e5aca139297ed84..2a1362759159b62f03750730839d085d33236361 100644 (file)
@@ -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;
index 8b7658ffa9cc499598562f082c1d97ba21462c87..c2c5fe389fca9bfaea2a7bfb60fab324d2f047b2 100644 (file)
@@ -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<FuelStation> result = new ArrayList<>();
+        ArrayList<FuelStation> large = new ArrayList<>();
+        ArrayList<FuelStation> medium = new ArrayList<>();
+        ArrayList<FuelStation> 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<FuelStation> result = new ArrayList<>();
         ArrayList<FuelStation> large = new ArrayList<>();
         ArrayList<FuelStation> 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) {
index 5a01f847debc0f5187eaede76013f4f652e95b03..24c36b093da520869bd8cd982246be1ca66294d7 100644 (file)
@@ -2,6 +2,8 @@ package de.diejungsvondertanke.tankstelle;
 
 /**
  * Possible {@link Fuel fuel} types
+ * 
+ * @author Robin Cheney
  */
 public enum FuelType {
     /**
index 05aba133e011978d7abb7e5b657b136266298100..b2a95c32347cfd4e807047179c98ca6da1cd4269 100644 (file)
@@ -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;
index 13a57195b88c6f0db0e0159071b6b62acdad749f..729ba11993c071e38fa9d5476156afacdcd99595 100644 (file)
@@ -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<FuelStation> result = new ArrayList<FuelStation>();
@@ -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<FuelStation> result = new ArrayList<FuelStation>();
@@ -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<FuelStation> result = new ArrayList<FuelStation>();
@@ -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<FuelStation> 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;
index bbabcfaa9eca18ace1ddf9563394aa84e81c3dfd..ff6636feeb9d1d8ae32e525802ae24515ecee28c 100644 (file)
@@ -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;
index 958627bfc29e116f180b357a61ebbacc28003b72..b4060810ad96753e20094466effc384363548a98 100644 (file)
@@ -9,6 +9,8 @@ package de.diejungsvondertanke.tankstelle;
  * @see LargeFuelStation
  * @see MediumFuelStation
  * @see SmallFuelStation
+ * 
+ * @author Robin Cheney
  */
 public enum Size {
     /**
index 6f660b6bcf5f9133cd5337a333d02461ee2639f4..e5f1e24842952a7af53dc3e3564579f77579d179 100644 (file)
@@ -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;
index 1ce5b47bf62fc1e7213b32a66f703cd9f74bd65a..8c8851e5f62e3f8c73913304f8c203f900339b35 100644 (file)
@@ -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();