From 9e8627cb86caeb4b3fc7f4f86ef5c3a37a152db5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Musil?= Date: Fri, 25 Dec 2020 18:46:06 +0100 Subject: [PATCH] Added money to Product --- .../fel/sit/omo/foodchain/node/NodeBase.java | 2 ++ .../sit/omo/foodchain/product/Product.java | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/NodeBase.java b/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/NodeBase.java index ede1db0..07b1425 100644 --- a/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/NodeBase.java +++ b/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/NodeBase.java @@ -118,6 +118,8 @@ public class NodeBase implements ChannelObserver { return SignatureManager.validateSignature(transaction); } + public MonetaryAmount getMoney() { return money; } + @Override public void update(Requirement requirement) { if (!requirement.getCreator().equals(this)) 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 7da8113..bf50960 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 @@ -2,11 +2,15 @@ package cz.cvut.fel.sit.omo.foodchain.product; import cz.cvut.fel.sit.omo.foodchain.operation.OperationBase; +import javax.money.Monetary; +import javax.money.MonetaryAmount; + public class Product { private ProductState productState; private ProductType productType; private OperationBase currentOperation; + private MonetaryAmount money; private String name; @@ -20,6 +24,15 @@ public class Product this.name = name; this.productType = productType; this.productState = ProductState.AVAILABLE; + this.money = Monetary.getDefaultAmountFactory().setCurrency("USD").setNumber(0).create(); + } + + public Product(String name, ProductType productType, MonetaryAmount money) + { + this.name = name; + this.productType = productType; + this.productState = ProductState.AVAILABLE; + this.money = money; } /** @@ -33,6 +46,15 @@ public class Product this.name = name; this.productType = productType; this.productState = productState; + this.money = Monetary.getDefaultAmountFactory().setCurrency("USD").setNumber(0).create(); + } + + public Product(String name, ProductType productType, ProductState productState, MonetaryAmount money) + { + this.name = name; + this.productType = productType; + this.productState = productState; + this.money = money; } // "State machine methods" @@ -121,4 +143,8 @@ public class Product { this.currentOperation = currentOperation; } + + public MonetaryAmount getMoney() { return money; } + + public void setMoney(MonetaryAmount money) { this.money = money; } }