diff --git a/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/base/NodeBase.java b/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/base/NodeBase.java index 8db8843..7b8988f 100644 --- a/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/base/NodeBase.java +++ b/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/base/NodeBase.java @@ -19,10 +19,10 @@ import java.util.*; public class NodeBase implements ChannelObserver { - private final Map subscribedChannels; - private final List products; - private final List refusedTransactions; - private final List refusedRequirements; + private final Map subscribedChannels = new HashMap<>(); + private final List products = new LinkedList<>(); + private final List refusedTransactions = new LinkedList<>(); + private final List refusedRequirements = new LinkedList<>(); private MonetaryAmount money; @@ -32,18 +32,11 @@ public class NodeBase implements ChannelObserver { public NodeBase() { this.nodeType = NodeType.None; - this.subscribedChannels = new HashMap<>(); - this.products = new LinkedList<>(); - this.refusedTransactions = new LinkedList<>(); - this.refusedRequirements = new LinkedList<>(); this.money = Money.of(0, "USD"); } public NodeBase(double m) { - this.subscribedChannels = new HashMap<>(); - this.products = new LinkedList<>(); - this.refusedTransactions = new LinkedList<>(); - this.refusedRequirements = new LinkedList<>(); + this.nodeType = NodeType.None; this.money = Money.of(m, "USD"); } @@ -271,18 +264,18 @@ public class NodeBase implements ChannelObserver { receiveTransactions(); //System.out.println(this.getClass().getSimpleName() + ": " + money.getNumber()); } -} -class RefusedRequirement { - public final TransactionType tType; - public final ProductType pType; - public final String pName; - public final MonetaryAmount price; + private static class RefusedRequirement { + public final TransactionType tType; + public final ProductType pType; + public final String pName; + public final MonetaryAmount price; - public RefusedRequirement(TransactionType tType, ProductType pType, String pName, MonetaryAmount price) { - this.tType = tType; - this.pType = pType; - this.pName = pName; - this.price = price; + public RefusedRequirement(TransactionType tType, ProductType pType, String pName, MonetaryAmount price) { + this.tType = tType; + this.pType = pType; + this.pName = pName; + this.price = price; + } } }