changed Storage to implement Unit

This commit is contained in:
Johannes Schmelz 2024-05-21 16:34:54 +00:00
parent c60c85ade0
commit a84a407c31
2 changed files with 8 additions and 8 deletions

View File

@ -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

View File

@ -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) {