Added nothing in fact...

This commit is contained in:
Daniel Poustka 2020-12-25 15:53:17 +01:00
parent 4193fdade4
commit 43eb9a2464
5 changed files with 76 additions and 21 deletions

View File

@ -1,4 +1,28 @@
package cz.cvut.fel.sit.omo.foodchain.factory; package cz.cvut.fel.sit.omo.foodchain.factory;
public class ChannelFactory {
import cz.cvut.fel.sit.omo.foodchain.channel.*;
public class ChannelFactory
{
public enum ChannelType
{
Fruit, Vegetable, Meat, Other;
}
public ChannelBase makeChannel(ChannelType typeOfChannel)
{
switch (typeOfChannel)
{
case Fruit:
return new FruitChannel();
case Vegetable:
return new VegetableChannel();
case Meat:
return new MeatChannel();
case Other:
return new OtherChannel();
}
return null;
}
} }

View File

@ -5,48 +5,68 @@ import cz.cvut.fel.sit.omo.foodchain.util.Singleton;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
public class FactoryManager { public class FactoryManager
//todo {
public NodeFactory getNodeFactoryInstance() { public NodeFactory getNodeFactoryInstance()
try { {
try
{
return Singleton.getInstance(NodeFactory.class); return Singleton.getInstance(NodeFactory.class);
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) { }
catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e)
{
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
public ChannelFactory getChannelFactoryInstance() { public ChannelFactory getChannelFactoryInstance()
try { {
try
{
return Singleton.getInstance(ChannelFactory.class); return Singleton.getInstance(ChannelFactory.class);
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) { }
catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e)
{
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
public ScenarioFactory getScenarioFactoryInstance() { public ScenarioFactory getScenarioFactoryInstance()
try { {
try
{
return Singleton.getInstance(ScenarioFactory.class); return Singleton.getInstance(ScenarioFactory.class);
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) { }
catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e)
{
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
public ProductFactory getProductFactoryInstance() { public ProductFactory getProductFactoryInstance()
try { {
try
{
return Singleton.getInstance(ProductFactory.class); return Singleton.getInstance(ProductFactory.class);
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) { }
catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e)
{
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
public PoolDatabase getPoolDatabaseInstance() { public PoolDatabase getPoolDatabaseInstance()
try { {
try
{
return Singleton.getInstance(PoolDatabase.class); return Singleton.getInstance(PoolDatabase.class);
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) { }
catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e)
{
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;

View File

@ -1,4 +1,6 @@
package cz.cvut.fel.sit.omo.foodchain.factory; package cz.cvut.fel.sit.omo.foodchain.factory;
public class NodeFactory { public class NodeFactory
{
//make
} }

View File

@ -1,4 +1,12 @@
package cz.cvut.fel.sit.omo.foodchain.factory; package cz.cvut.fel.sit.omo.foodchain.factory;
public class ProductFactory { import cz.cvut.fel.sit.omo.foodchain.product.Product;
import cz.cvut.fel.sit.omo.foodchain.product.ProductType;
public class ProductFactory
{
public Product makeProduct(String name, ProductType productType)
{
return new Product(name, productType);
}
} }

View File

@ -1,4 +1,5 @@
package cz.cvut.fel.sit.omo.foodchain.factory; package cz.cvut.fel.sit.omo.foodchain.factory;
public class ScenarioFactory { public class ScenarioFactory
{
} }