From a84a407c31e8c34d97d8c3d5ee874dcd4a348b8a Mon Sep 17 00:00:00 2001 From: peet Date: Tue, 21 May 2024 16:34:54 +0000 Subject: [PATCH] changed Storage to implement Unit --- src/uebung05/logistics/storage/FloatStorage.java | 6 +++--- src/uebung05/logistics/storage/IntStorage.java | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/uebung05/logistics/storage/FloatStorage.java b/src/uebung05/logistics/storage/FloatStorage.java index bc14d22..9c42a30 100755 --- a/src/uebung05/logistics/storage/FloatStorage.java +++ b/src/uebung05/logistics/storage/FloatStorage.java @@ -11,11 +11,11 @@ import logistics.quantities.NeedCollector; * @author Nikolaus Köberlein * @version 1.0 */ -public class FloatStorage { +public class FloatStorage implements FloatUnit { - private FloatUnit unit; + private final FloatUnit unit; private float stored; - private float max; + private final float max; /** * Construct a FloatStorage object with a stored amount, FloatUnit object, and maximum capacity diff --git a/src/uebung05/logistics/storage/IntStorage.java b/src/uebung05/logistics/storage/IntStorage.java index c1c5b12..0092f91 100755 --- a/src/uebung05/logistics/storage/IntStorage.java +++ b/src/uebung05/logistics/storage/IntStorage.java @@ -11,11 +11,11 @@ import logistics.quantities.NeedCollector; * @author Nikolaus Köberlein * @version 1.0 */ -public class IntStorage { +public class IntStorage implements IntUnit { - private IntUnit unit; + private final IntUnit unit; private int stored; - private int max; + private final int max; /** * Construct an IntStorage object with a stored amount, IntUnit object, and maximum capacity @@ -94,11 +94,11 @@ public class IntStorage { * * @param amount The amount to fill the IntStorage object with * - * @throws java.lang.IllegalArgumentException if consume is negative + * @throws java.lang.IllegalArgumentException if amount is negative */ public void fill(int amount) { if (amount < 0) { - throw new IllegalArgumentException("Consume cannot be negative"); + throw new IllegalArgumentException("Filled amount cannot be negative"); } stored += amount; if (max < stored) {