]> Git Server - tankstelle.git/commitdiff
added get_cumulative_retail_price method to get the accumulative price as if all...
authorRobin Cheney <cheneyr@eternal.ddnss.de>
Thu, 13 Nov 2025 07:50:15 +0000 (08:50 +0100)
committerRobin Cheney <cheneyr@eternal.ddnss.de>
Thu, 13 Nov 2025 07:50:15 +0000 (08:50 +0100)
src/main/java/de/diejungsvondertanke/tankstelle/FuelStation.java
src/main/java/de/diejungsvondertanke/tankstelle/LargeFuelStation.java
src/main/java/de/diejungsvondertanke/tankstelle/MediumFuelStation.java
src/main/java/de/diejungsvondertanke/tankstelle/SmallFuelStation.java

index babe1bb877616143a2d7d1dffe67ae366d016722..f1eac38b0f7aeb261dd2b190127b8712f2733ebd 100644 (file)
@@ -121,4 +121,20 @@ abstract class FuelStation {
         throw new NoSuchFuelTypeError("This fuel station does not have fuel of the given type");
     }
 
+    /**
+     * Get the cumulative price for the amount of fuel stored
+     * 
+     * => What you would get if you would sell all fuel of this station at the
+     * current prices
+     * 
+     * @return the income in €
+     */
+    public double get_cumulative_retail_price() {
+        double result = 0;
+        for (Fuel i : fuels) {
+            result += i.getPrice() * i.getStored_amount();
+        }
+        return result;
+    }
+
 }
index cc7a78fe3b2d337b6fd1bc9ae9690551e8a891b1..7d19b2ce2d87e8504a2d226453227b186859bdd7 100644 (file)
@@ -16,11 +16,11 @@ public class LargeFuelStation extends FuelStation {
      * @see #supermarket_company
      */
     public LargeFuelStation(String supermarket_company) {
-        super((byte) 4, Size.LARGE, new Fuel[] { new Fuel(FuelType.SUPER, 8000f, 0f, 16000),
-                new Fuel(FuelType.SUPER_E10, 8000f, 0f, 16000),
-                new Fuel(FuelType.DIESEL, 8000f, 0f, 16000),
-                new Fuel(FuelType.PREMIUM_DIESEL, 8000f, 0f, 16000),
-                new Fuel(FuelType.AUTOGAS, 8000f, 0f, 16000) });
+        super((byte) 4, Size.LARGE, new Fuel[] { new Fuel(FuelType.SUPER, 8000f, 1.7f, 16000),
+                new Fuel(FuelType.SUPER_E10, 8000f, 1.7f, 16000),
+                new Fuel(FuelType.DIESEL, 8000f, 1.7f, 16000),
+                new Fuel(FuelType.PREMIUM_DIESEL, 8000f, 1.7f, 16000),
+                new Fuel(FuelType.AUTOGAS, 8000f, 1.7f, 16000) });
         this.supermarket_company = supermarket_company;
     }
 
@@ -33,11 +33,11 @@ public class LargeFuelStation extends FuelStation {
      * @see FuelStation#number_of_employees
      */
     public LargeFuelStation(String supermarket_company, byte number_of_employees) {
-        super(number_of_employees, Size.LARGE, new Fuel[] { new Fuel(FuelType.SUPER, 8000f, 0f, 16000),
-                new Fuel(FuelType.SUPER_E10, 8000f, 0f, 16000),
-                new Fuel(FuelType.DIESEL, 8000f, 0f, 16000),
-                new Fuel(FuelType.PREMIUM_DIESEL, 8000f, 0f, 16000),
-                new Fuel(FuelType.AUTOGAS, 8000f, 0f, 16000) });
+        super(number_of_employees, Size.LARGE, new Fuel[] { new Fuel(FuelType.SUPER, 8000f, 1.7f, 16000),
+                new Fuel(FuelType.SUPER_E10, 8000f, 1.7f, 16000),
+                new Fuel(FuelType.DIESEL, 8000f, 1.7f, 16000),
+                new Fuel(FuelType.PREMIUM_DIESEL, 8000f, 1.7f, 16000),
+                new Fuel(FuelType.AUTOGAS, 8000f, 1.7f, 16000) });
         this.supermarket_company = supermarket_company;
     }
 
index f4d96d3c37ced94b398baa21bdc5a18eb37ff7af..9b7bd553295fb2956e31b64abf548985c24baafc 100644 (file)
@@ -16,10 +16,10 @@ public class MediumFuelStation extends FuelStation {
      * @see #retail_space retail_space
      */
     public MediumFuelStation(float retail_space) {
-        super((byte) 2, Size.MEDIUM, new Fuel[] { new Fuel(FuelType.SUPER, 6000f, 0f, 12000),
-                new Fuel(FuelType.SUPER_E10, 6000f, 0f, 12000),
-                new Fuel(FuelType.PREMIUM_DIESEL, 6000f, 0f, 12000),
-                new Fuel(FuelType.AUTOGAS, 6000f, 0f, 12000) });
+        super((byte) 2, Size.MEDIUM, new Fuel[] { new Fuel(FuelType.SUPER, 6000f, 1.7f, 12000),
+                new Fuel(FuelType.SUPER_E10, 6000f, 1.7f, 12000),
+                new Fuel(FuelType.PREMIUM_DIESEL, 6000f, 1.7f, 12000),
+                new Fuel(FuelType.AUTOGAS, 6000f, 1.7f, 12000) });
         this.retail_space = retail_space;
     }
 
@@ -32,10 +32,10 @@ public class MediumFuelStation extends FuelStation {
      * @see FuelStation#number_of_employees
      */
     public MediumFuelStation(float retail_space, byte number_of_employees) {
-        super(number_of_employees, Size.MEDIUM, new Fuel[] { new Fuel(FuelType.SUPER, 6000f, 0f, 12000),
-                new Fuel(FuelType.SUPER_E10, 6000f, 0f, 12000),
-                new Fuel(FuelType.PREMIUM_DIESEL, 6000f, 0f, 12000),
-                new Fuel(FuelType.AUTOGAS, 6000f, 0f, 12000) });
+        super(number_of_employees, Size.MEDIUM, new Fuel[] { new Fuel(FuelType.SUPER, 6000f, 1.7f, 12000),
+                new Fuel(FuelType.SUPER_E10, 6000f, 1.7f, 12000),
+                new Fuel(FuelType.PREMIUM_DIESEL, 6000f, 1.7f, 12000),
+                new Fuel(FuelType.AUTOGAS, 6000f, 1.7f, 12000) });
         this.retail_space = retail_space;
     }
 
index 98ab3b0a5f6b49c15507eec3e3b3cfafafc3f424..96f379a2c8eb0395b725f0439787fecc1c441ffc 100644 (file)
@@ -16,8 +16,8 @@ public class SmallFuelStation extends FuelStation {
      * @see #number_of_vending_machines
      */
     public SmallFuelStation(short number_of_vending_machines) {
-        super((byte) 1, Size.SMALL, new Fuel[] { new Fuel(FuelType.SUPER, 4000f, 0f, 8000),
-                new Fuel(FuelType.DIESEL, 4000f, 0f, 8000) });
+        super((byte) 1, Size.SMALL, new Fuel[] { new Fuel(FuelType.SUPER, 4000f, 1.68f, 8000),
+                new Fuel(FuelType.DIESEL, 4000f, 1.7f, 8000) });
         this.number_of_vending_machines = number_of_vending_machines;
     }
 
@@ -30,8 +30,8 @@ public class SmallFuelStation extends FuelStation {
      * @see FuelStation#number_of_employees
      */
     public SmallFuelStation(short number_of_vending_machines, byte number_of_employees) {
-        super(number_of_employees, Size.SMALL, new Fuel[] { new Fuel(FuelType.SUPER, 4000f, 0f, 8000),
-                new Fuel(FuelType.DIESEL, 4000f, 0f, 8000) });
+        super(number_of_employees, Size.SMALL, new Fuel[] { new Fuel(FuelType.SUPER, 4000f, 1.68f, 8000),
+                new Fuel(FuelType.DIESEL, 4000f, 1.7f, 8000) });
         this.number_of_vending_machines = number_of_vending_machines;
     }