Merge branch 'develop' into feature/factory_impl
# Conflicts: # src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/NodeFactory.java # src/main/java/cz/cvut/fel/sit/omo/foodchain/product/Product.java
This commit is contained in:
commit
015d558afe
Binary file not shown.
@ -4,6 +4,10 @@ import java.util.Random;
|
|||||||
|
|
||||||
public class Customer extends BuyerNodeBase {
|
public class Customer extends BuyerNodeBase {
|
||||||
|
|
||||||
|
public Customer(int startMoney) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
public void consumeProduct() {
|
public void consumeProduct() {
|
||||||
int i = new Random().nextInt(getStorage().size());
|
int i = new Random().nextInt(getStorage().size());
|
||||||
getStorage().remove(i);
|
getStorage().remove(i);
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.node;
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
public class Distributor extends RetailerNodeBase {
|
public class Distributor extends RetailerNodeBase {
|
||||||
|
|
||||||
|
public Distributor(int startMoney) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,10 @@ import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
|||||||
|
|
||||||
public class Farmer extends SellerNodeBase {
|
public class Farmer extends SellerNodeBase {
|
||||||
|
|
||||||
|
public Farmer(int startMoney) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
public void generateProduct(Product product) {
|
public void generateProduct(Product product) {
|
||||||
storeProduct(product);
|
storeProduct(product);
|
||||||
createRequirement(TransactionType.SALE, product.getProductType(), product.getName());
|
createRequirement(TransactionType.SALE, product.getProductType(), product.getName());
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public class NodeBase implements ChannelObserver {
|
|||||||
money = Monetary.getDefaultAmountFactory().setCurrency("USD").setNumber(0).create();
|
money = Monetary.getDefaultAmountFactory().setCurrency("USD").setNumber(0).create();
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeBase(int m) {
|
public NodeBase(double m) {
|
||||||
subscribedChannels = new HashMap<>();
|
subscribedChannels = new HashMap<>();
|
||||||
products = new LinkedList<>();
|
products = new LinkedList<>();
|
||||||
refusedTranslations = new LinkedList<>();
|
refusedTranslations = new LinkedList<>();
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.node;
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
public class Processor extends RetailerNodeBase {
|
public class Processor extends RetailerNodeBase {
|
||||||
|
|
||||||
|
public Processor(int startMoney) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.node;
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
public class Seller extends RetailerNodeBase {
|
public class Seller extends RetailerNodeBase {
|
||||||
|
|
||||||
|
public Seller(int startMoney) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,7 +72,7 @@ public class Product
|
|||||||
*/
|
*/
|
||||||
public void setStateToReadyForDispatch()
|
public void setStateToReadyForDispatch()
|
||||||
{
|
{
|
||||||
if (this.productState.equals(ProductState.AVAILABLE))
|
if(this.productState.equals(ProductState.AVAILABLE))
|
||||||
this.productState = ProductState.READY_FOR_DISPATCH;
|
this.productState = ProductState.READY_FOR_DISPATCH;
|
||||||
else
|
else
|
||||||
throw new IllegalStateException("Cannot set state READY_FOR_DISPATCH. Product is not AVAILABLE!");
|
throw new IllegalStateException("Cannot set state READY_FOR_DISPATCH. Product is not AVAILABLE!");
|
||||||
@ -83,7 +83,7 @@ public class Product
|
|||||||
*/
|
*/
|
||||||
public void setStateToInTransit()
|
public void setStateToInTransit()
|
||||||
{
|
{
|
||||||
if (this.productState.equals(ProductState.READY_FOR_DISPATCH))
|
if(this.productState.equals(ProductState.READY_FOR_DISPATCH))
|
||||||
this.productState = ProductState.IN_TRANSIT;
|
this.productState = ProductState.IN_TRANSIT;
|
||||||
else
|
else
|
||||||
throw new IllegalStateException("Cannot set state IN_TRANSIT. Product is not READY_FOR_DISPATCH!");
|
throw new IllegalStateException("Cannot set state IN_TRANSIT. Product is not READY_FOR_DISPATCH!");
|
||||||
@ -94,7 +94,7 @@ public class Product
|
|||||||
*/
|
*/
|
||||||
public void setStateToReadyForReception()
|
public void setStateToReadyForReception()
|
||||||
{
|
{
|
||||||
if (this.productState.equals(ProductState.IN_TRANSIT))
|
if(this.productState.equals(ProductState.IN_TRANSIT))
|
||||||
this.productState = ProductState.READY_FOR_RECEPTION;
|
this.productState = ProductState.READY_FOR_RECEPTION;
|
||||||
else
|
else
|
||||||
throw new IllegalStateException("Cannot set state READY_FOR_RECEPTION. Product has not been in transit!");
|
throw new IllegalStateException("Cannot set state READY_FOR_RECEPTION. Product has not been in transit!");
|
||||||
@ -144,13 +144,7 @@ public class Product
|
|||||||
this.currentOperation = currentOperation;
|
this.currentOperation = currentOperation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MonetaryAmount getMoney()
|
public MonetaryAmount getMoney() { return money; }
|
||||||
{
|
|
||||||
return money;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMoney(MonetaryAmount money)
|
public void setMoney(MonetaryAmount money) { this.money = money; }
|
||||||
{
|
|
||||||
this.money = money;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user