From 22369d7b704196121604851396efc2e836c61394 Mon Sep 17 00:00:00 2001 From: Daniel Poustka Date: Sat, 26 Dec 2020 10:16:42 +0100 Subject: [PATCH] Fixed some stuff --- .../omo/foodchain/factory/NodeFactory.java | 42 +++++++++---------- .../sit/omo/foodchain/product/Product.java | 1 - 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/NodeFactory.java b/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/NodeFactory.java index 91a2c1a..15c2f16 100644 --- a/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/NodeFactory.java +++ b/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/NodeFactory.java @@ -25,14 +25,14 @@ public class NodeFactory NodeBase n = null; NodeType nodeType = null; String subsChannels = ""; - int startMoney = 0; + double startMoney = 0; try { nodeType = NodeType.valueOf(input.getAttribute("type")); subsChannels = input.getChild("subscribed_channels"); - startMoney = Integer.getInteger(input.getChild("money")); + startMoney = Double.parseDouble(input.getChild("money")); } catch (IllegalArgumentException e) { @@ -43,25 +43,25 @@ public class NodeFactory System.err.println("! Fatal error in NodeFactory: " + e.getMessage()); } -// switch (Objects.requireNonNull(nodeType)) -// { -// //TODO Money constructor -// case Farmer: -// n = new Farmer(startMoney); -// break; -// case Processor: -// n = new Processor(startMoney); -// break; -// case Distributor: -// n = new Distributor(startMoney); -// break; -// case Seller: -// n = new Seller(startMoney); -// break; -// case Customer: -// n = new Customer(startMoney); -// break; -// } + switch (Objects.requireNonNull(nodeType)) + { + //TODO Money constructor + case Farmer: + n = new Farmer(startMoney); + break; + case Processor: + n = new Processor(startMoney); + break; + case Distributor: + n = new Distributor(startMoney); + break; + case Seller: + n = new Seller(startMoney); + break; + case Customer: + n = new Customer(startMoney); + break; + } String[] subs = subsChannels.split(";"); //todo Node subscription to channels by parser data diff --git a/src/main/java/cz/cvut/fel/sit/omo/foodchain/product/Product.java b/src/main/java/cz/cvut/fel/sit/omo/foodchain/product/Product.java index 2156d61..cc36755 100644 --- a/src/main/java/cz/cvut/fel/sit/omo/foodchain/product/Product.java +++ b/src/main/java/cz/cvut/fel/sit/omo/foodchain/product/Product.java @@ -27,7 +27,6 @@ public class Product this.money = Monetary.getDefaultAmountFactory().setCurrency("USD").setNumber(0).create(); } - //TODO money int constructor public Product(String name, ProductType productType, Double money) { this.name = name;