Merge branch 'feature/node_impl' into develop
This commit is contained in:
commit
a2b5c2bc92
@ -10,6 +10,7 @@
|
||||
generate
|
||||
consume
|
||||
doaction <product-operation-type>
|
||||
doaction <product-operation-type> <product-name>
|
||||
sell <product-type> <product-name>
|
||||
buy <product-type> <produt-name> <product-price>
|
||||
pass
|
||||
|
||||
@ -41,8 +41,6 @@ public class FoodChain
|
||||
return factoryManager;
|
||||
}
|
||||
|
||||
// todo maybe some refactoring needed?
|
||||
// add other entities
|
||||
public static void parseChannels()
|
||||
{
|
||||
try
|
||||
|
||||
@ -76,6 +76,17 @@ public class Storage
|
||||
return products.contains(product);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether storage contains provided product
|
||||
* @param name name of product to check
|
||||
* @param type type of product to check
|
||||
* @return true if contains, false if not
|
||||
*/
|
||||
public boolean containsProduct(String name, ProductType type)
|
||||
{
|
||||
return this.getProduct(name,type) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes provided product from storage if storage contains this product. (Removes only first found)
|
||||
* @param product product to remove
|
||||
@ -94,8 +105,10 @@ public class Storage
|
||||
public void doAction(ProductOperationType action, Product product) throws IllegalCallerException
|
||||
{
|
||||
if (action.getNode().equals(this.storageOwner.getNodeType()))
|
||||
new Action(this.storageOwner, this.getProduct(product.getName(), product.getProductType()), action);
|
||||
//new Action(this.storageOwner, product, action); //todo má se zpracovat produkt co přichází nebo na jeho základě najít tento produkt ve skladu a ten zpracovat???
|
||||
if (action.getProduct().equals(product.getProductType()) || action.getProduct().equals(ProductType.ALL))
|
||||
new Action(this.storageOwner, product, action);
|
||||
else
|
||||
throw new IllegalCallerException("! IllegalCallerException in NodeBase. " + product.getProductType().toString() + " cannot be processed by action " + action.name() + " only for " + action.getProduct());
|
||||
else
|
||||
throw new IllegalCallerException("! IllegalCallerException in NodeBase. " + this.storageOwner.getNodeType().toString() + " cannot do action available only for " + action.getNode());
|
||||
}
|
||||
|
||||
@ -1,36 +1,36 @@
|
||||
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||
|
||||
import cz.cvut.fel.sit.omo.foodchain.node.enums.NodeType;
|
||||
import cz.cvut.fel.sit.omo.foodchain.product.ProductType;
|
||||
|
||||
public enum ProductOperationType
|
||||
{
|
||||
STORE_MEAT(NodeType.All, 20, -8),
|
||||
STORE_FRUIT(NodeType.All, 8, 2),
|
||||
STORE_VEGETABLE(NodeType.All, 10, 2),
|
||||
STORE_OTHER(NodeType.All, 30, 21),
|
||||
STORE_MEAT(NodeType.All, ProductType.MEAT, 20, -8),
|
||||
STORE_FRUIT(NodeType.All, ProductType.FRUIT, 8, 2),
|
||||
STORE_VEGETABLE(NodeType.All, ProductType.VEGETABLE, 10, 2),
|
||||
STORE_OTHER(NodeType.All, ProductType.OTHER, 30, 21),
|
||||
|
||||
WRAP_INTO_GIFT_PACKAGE(NodeType.Seller, 1, -8),
|
||||
UNWRAP(NodeType.All, 1, 21),
|
||||
CUT_TO_PIECES(NodeType.All, 1, 21),
|
||||
WRAP_INTO_GIFT_PACKAGE(NodeType.Seller, ProductType.ALL, 1, -8),
|
||||
UNWRAP(NodeType.All, ProductType.ALL, 1, 21),
|
||||
CUT_TO_PIECES(NodeType.All, ProductType.ALL, 1, 21),
|
||||
|
||||
BOIL_MEAT(NodeType.All, 1, 21),
|
||||
GRILL_MEAT(NodeType.All, 1, 21),
|
||||
SMOKE_MEAT(NodeType.All, 1, 21),
|
||||
DRY_MEAT(NodeType.All, 1, 21),
|
||||
BOIL_MEAT(NodeType.All, ProductType.MEAT, 1, 21),
|
||||
GRILL_MEAT(NodeType.All, ProductType.MEAT, 1, 21),
|
||||
SMOKE_MEAT(NodeType.All, ProductType.MEAT, 1, 21),
|
||||
DRY_MEAT(NodeType.All, ProductType.MEAT, 1, 21),
|
||||
|
||||
DRY_FRUIT(NodeType.All, 1, 21),
|
||||
FREEZE_DRY_FRUIT(NodeType.All, 1, 21);
|
||||
|
||||
|
||||
//todo add product type allowed for this action
|
||||
DRY_FRUIT(NodeType.All, ProductType.FRUIT, 1, 21),
|
||||
FREEZE_DRY_FRUIT(NodeType.All, ProductType.FRUIT, 1, 21);
|
||||
|
||||
private final NodeType node;
|
||||
private final ProductType product;
|
||||
private final int duration;
|
||||
private final int temperature;
|
||||
|
||||
ProductOperationType(NodeType node, int duration, int temperature)
|
||||
ProductOperationType(NodeType node, ProductType product, int duration, int temperature)
|
||||
{
|
||||
this.node = node;
|
||||
this.product = product;
|
||||
this.duration = duration;
|
||||
this.temperature = temperature;
|
||||
}
|
||||
@ -49,4 +49,6 @@ public enum ProductOperationType
|
||||
{
|
||||
return node;
|
||||
}
|
||||
|
||||
public ProductType getProduct() { return product; }
|
||||
}
|
||||
|
||||
@ -2,5 +2,5 @@ package cz.cvut.fel.sit.omo.foodchain.product;
|
||||
|
||||
public enum ProductType
|
||||
{
|
||||
MEAT, FRUIT, VEGETABLE, OTHER;
|
||||
MEAT, FRUIT, VEGETABLE, OTHER, ALL // ALL is used only for actions
|
||||
}
|
||||
|
||||
@ -22,7 +22,6 @@ public class DoActionStep extends ScenarioStep {
|
||||
|
||||
@Override
|
||||
void execute() {
|
||||
//todo maybe do a better error handling
|
||||
try {
|
||||
if (product != null) {
|
||||
nodeBase.doAction(productOperationType, product);
|
||||
|
||||
@ -8,7 +8,6 @@ public class Scenario {
|
||||
Iterator<ScenarioStep> stepIterator;
|
||||
|
||||
public Scenario() {
|
||||
//steps = //TODO init
|
||||
stepIterator = steps.listIterator(0);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user