changed Storage to implement Unit
This commit is contained in:
parent
c60c85ade0
commit
a84a407c31
@ -11,11 +11,11 @@ import logistics.quantities.NeedCollector;
|
|||||||
* @author Nikolaus Köberlein
|
* @author Nikolaus Köberlein
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class FloatStorage {
|
public class FloatStorage implements FloatUnit {
|
||||||
|
|
||||||
private FloatUnit unit;
|
private final FloatUnit unit;
|
||||||
private float stored;
|
private float stored;
|
||||||
private float max;
|
private final float max;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a FloatStorage object with a stored amount, FloatUnit object, and maximum capacity
|
* Construct a FloatStorage object with a stored amount, FloatUnit object, and maximum capacity
|
||||||
|
@ -11,11 +11,11 @@ import logistics.quantities.NeedCollector;
|
|||||||
* @author Nikolaus Köberlein
|
* @author Nikolaus Köberlein
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class IntStorage {
|
public class IntStorage implements IntUnit {
|
||||||
|
|
||||||
private IntUnit unit;
|
private final IntUnit unit;
|
||||||
private int stored;
|
private int stored;
|
||||||
private int max;
|
private final int max;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an IntStorage object with a stored amount, IntUnit object, and maximum capacity
|
* 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
|
* @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) {
|
public void fill(int amount) {
|
||||||
if (amount < 0) {
|
if (amount < 0) {
|
||||||
throw new IllegalArgumentException("Consume cannot be negative");
|
throw new IllegalArgumentException("Filled amount cannot be negative");
|
||||||
}
|
}
|
||||||
stored += amount;
|
stored += amount;
|
||||||
if (max < stored) {
|
if (max < stored) {
|
||||||
|
Loading…
Reference in New Issue
Block a user