Changed NodeBase structure a bit

This commit is contained in:
Tomáš Musil 2020-12-28 16:54:34 +01:00
parent 1bea53d11b
commit 63a4697a64

View File

@ -19,10 +19,10 @@ import java.util.*;
public class NodeBase implements ChannelObserver {
private final Map<ChannelBase, ChannelSubscriptionType> subscribedChannels;
private final List<Product> products;
private final List<Transaction> refusedTransactions;
private final List<RefusedRequirement> refusedRequirements;
private final Map<ChannelBase, ChannelSubscriptionType> subscribedChannels = new HashMap<>();
private final List<Product> products = new LinkedList<>();
private final List<Transaction> refusedTransactions = new LinkedList<>();
private final List<RefusedRequirement> 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;
}
}
}