Renamed classes, added more interface methods
This commit is contained in:
parent
021c194839
commit
5e4ea372d0
@ -1,4 +1,7 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain;
|
package cz.cvut.fel.sit.omo.foodchain;
|
||||||
|
|
||||||
public class FoodChain {
|
public class FoodChain {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +0,0 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.channel;
|
|
||||||
|
|
||||||
public interface Channel {
|
|
||||||
}
|
|
||||||
@ -1,4 +1,11 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.channel;
|
package cz.cvut.fel.sit.omo.foodchain.channel;
|
||||||
|
|
||||||
public abstract class ChannelBase implements Channel {
|
import cz.cvut.fel.sit.omo.foodchain.operation.Transaction;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.requirement.Requirement;
|
||||||
|
|
||||||
|
import java.util.Queue;
|
||||||
|
|
||||||
|
public abstract class ChannelBase implements IChannel {
|
||||||
|
Queue<Requirement> requirements;
|
||||||
|
Queue<Transaction> transactions;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,26 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.channel;
|
package cz.cvut.fel.sit.omo.foodchain.channel;
|
||||||
|
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.operation.Transaction;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.requirement.Requirement;
|
||||||
|
|
||||||
public class FruitChannel extends ChannelBase {
|
public class FruitChannel extends ChannelBase {
|
||||||
|
@Override
|
||||||
|
public Transaction getNextTransaction() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Requirement getNextRequirement() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addRequirement(Requirement requirement) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addTransaction(Transaction transaction) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,12 @@
|
|||||||
|
package cz.cvut.fel.sit.omo.foodchain.channel;
|
||||||
|
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.operation.Transaction;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.requirement.Requirement;
|
||||||
|
|
||||||
|
public interface IChannel {
|
||||||
|
public Transaction getNextTransaction();
|
||||||
|
public Requirement getNextRequirement();
|
||||||
|
|
||||||
|
public void addRequirement(Requirement requirement);
|
||||||
|
public void addTransaction(Transaction transaction);
|
||||||
|
}
|
||||||
@ -1,4 +1,26 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.channel;
|
package cz.cvut.fel.sit.omo.foodchain.channel;
|
||||||
|
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.operation.Transaction;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.requirement.Requirement;
|
||||||
|
|
||||||
public class MeetChannel extends ChannelBase {
|
public class MeetChannel extends ChannelBase {
|
||||||
|
@Override
|
||||||
|
public Transaction getNextTransaction() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Requirement getNextRequirement() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addRequirement(Requirement requirement) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addTransaction(Transaction transaction) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,26 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.channel;
|
package cz.cvut.fel.sit.omo.foodchain.channel;
|
||||||
|
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.operation.Transaction;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.requirement.Requirement;
|
||||||
|
|
||||||
public class VegetableChannel extends ChannelBase {
|
public class VegetableChannel extends ChannelBase {
|
||||||
|
@Override
|
||||||
|
public Transaction getNextTransaction() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Requirement getNextRequirement() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addRequirement(Requirement requirement) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addTransaction(Transaction transaction) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package cz.cvut.fel.sit.omo.foodchain.node;
|
|||||||
|
|
||||||
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||||
|
|
||||||
public class BuyerNodeBase extends NodeBase implements BuyerNodeInterface {
|
public class BuyerNodeBase extends NodeBase implements IBuyerNode {
|
||||||
@Override
|
@Override
|
||||||
public void sellProduct(Product product) {
|
public void sellProduct(Product product) {
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package cz.cvut.fel.sit.omo.foodchain.node;
|
|||||||
|
|
||||||
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||||
|
|
||||||
public interface BuyerNodeInterface {
|
public interface IBuyerNode {
|
||||||
|
|
||||||
void sellProduct(Product product);
|
void sellProduct(Product product);
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.node;
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
import cz.cvut.fel.sit.omo.foodchain.channel.Channel;
|
import cz.cvut.fel.sit.omo.foodchain.channel.IChannel;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.operation.Action;
|
import cz.cvut.fel.sit.omo.foodchain.operation.Action;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.operation.Transaction;
|
import cz.cvut.fel.sit.omo.foodchain.operation.Transaction;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||||
@ -10,22 +10,22 @@ import cz.cvut.fel.sit.omo.foodchain.signature.Signature;
|
|||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public interface NodeInterface {
|
public interface INode {
|
||||||
void sendTransaction(Product product, NodeInterface node);
|
void sendTransaction(Product product, INode INode);
|
||||||
|
|
||||||
void receiveTransaction(Transaction transaction);
|
void receiveTransaction(Transaction transaction);
|
||||||
|
|
||||||
void refuseTransaction(Transaction transaction);
|
void refuseTransaction(Transaction transaction);
|
||||||
|
|
||||||
Transaction readNextTransaction(Channel channel);
|
Transaction readNextTransaction(IChannel channel);
|
||||||
|
|
||||||
Requirement readNextRequirement(Channel channel);
|
Requirement readNextRequirement(IChannel channel);
|
||||||
|
|
||||||
void acceptRequirement(Requirement requirement);
|
void acceptRequirement(Requirement requirement);
|
||||||
|
|
||||||
void subscribeToChannel(Channel channel);
|
void subscribeToChannel(IChannel channel);
|
||||||
|
|
||||||
void unsubscribeFromChannel(Channel channel);
|
void unsubscribeFromChannel(IChannel channel);
|
||||||
|
|
||||||
void doAction(Action action, Product product);
|
void doAction(Action action, Product product);
|
||||||
|
|
||||||
@ -2,7 +2,7 @@ package cz.cvut.fel.sit.omo.foodchain.node;
|
|||||||
|
|
||||||
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||||
|
|
||||||
public interface SellerNodeInterface {
|
public interface ISellerNode {
|
||||||
|
|
||||||
void buyProduct(Product product);
|
void buyProduct(Product product);
|
||||||
}
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.node;
|
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||||
|
|
||||||
import cz.cvut.fel.sit.omo.foodchain.channel.Channel;
|
import cz.cvut.fel.sit.omo.foodchain.channel.IChannel;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.operation.Action;
|
import cz.cvut.fel.sit.omo.foodchain.operation.Action;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.operation.Transaction;
|
import cz.cvut.fel.sit.omo.foodchain.operation.Transaction;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||||
@ -10,9 +10,9 @@ import cz.cvut.fel.sit.omo.foodchain.signature.Signature;
|
|||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class NodeBase implements NodeInterface {
|
public class NodeBase implements INode {
|
||||||
@Override
|
@Override
|
||||||
public void sendTransaction(Product product, NodeInterface node) {
|
public void sendTransaction(Product product, INode node) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,12 +27,12 @@ public class NodeBase implements NodeInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Transaction readNextTransaction(Channel channel) {
|
public Transaction readNextTransaction(IChannel channel) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Requirement readNextRequirement(Channel channel) {
|
public Requirement readNextRequirement(IChannel channel) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,12 +42,12 @@ public class NodeBase implements NodeInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void subscribeToChannel(Channel channel) {
|
public void subscribeToChannel(IChannel channel) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unsubscribeFromChannel(Channel channel) {
|
public void unsubscribeFromChannel(IChannel channel) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package cz.cvut.fel.sit.omo.foodchain.node;
|
|||||||
|
|
||||||
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||||
|
|
||||||
public class RetailerNodeBase extends NodeBase implements BuyerNodeInterface, SellerNodeInterface {
|
public class RetailerNodeBase extends NodeBase implements IBuyerNode, ISellerNode {
|
||||||
@Override
|
@Override
|
||||||
public void sellProduct(Product product) {
|
public void sellProduct(Product product) {
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package cz.cvut.fel.sit.omo.foodchain.node;
|
|||||||
|
|
||||||
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||||
|
|
||||||
public class SellerNodeBase extends NodeBase implements SellerNodeInterface {
|
public class SellerNodeBase extends NodeBase implements ISellerNode {
|
||||||
@Override
|
@Override
|
||||||
public void buyProduct(Product product) {
|
public void buyProduct(Product product) {
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.operation;
|
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||||
|
|
||||||
public interface OperationInterface {
|
public interface IOperation {
|
||||||
}
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.operation;
|
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||||
|
|
||||||
public class OperationBase {
|
public class OperationBase {
|
||||||
|
IOperation lastOperation;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.pool;
|
package cz.cvut.fel.sit.omo.foodchain.pool;
|
||||||
|
|
||||||
import cz.cvut.fel.sit.omo.foodchain.channel.Channel;
|
import cz.cvut.fel.sit.omo.foodchain.channel.IChannel;
|
||||||
|
|
||||||
public class ChannelPool extends PoolListBase<Channel> {
|
public class ChannelPool extends PoolListBase<IChannel> {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package cz.cvut.fel.sit.omo.foodchain.pool;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public interface PoolInterface<T> {
|
public interface IPool<T> {
|
||||||
Collection<T> findAll();
|
Collection<T> findAll();
|
||||||
|
|
||||||
void add(T element);
|
void add(T element);
|
||||||
@ -1,6 +1,6 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.pool;
|
package cz.cvut.fel.sit.omo.foodchain.pool;
|
||||||
|
|
||||||
import cz.cvut.fel.sit.omo.foodchain.node.NodeInterface;
|
import cz.cvut.fel.sit.omo.foodchain.node.INode;
|
||||||
|
|
||||||
public class NodePool extends PoolListBase<NodeInterface> {
|
public class NodePool extends PoolListBase<INode> {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import java.util.Collection;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class PoolListBase<T> implements PoolInterface<T> {
|
public abstract class PoolListBase<T> implements IPool<T> {
|
||||||
List<T> pool;
|
List<T> pool;
|
||||||
|
|
||||||
public PoolListBase() {
|
public PoolListBase() {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.product;
|
package cz.cvut.fel.sit.omo.foodchain.product;
|
||||||
|
|
||||||
public class ProductState {
|
public enum ProductState {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,19 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.reporting;
|
package cz.cvut.fel.sit.omo.foodchain.reporting;
|
||||||
|
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.channel.IChannel;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.node.INode;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.operation.IOperation;
|
||||||
|
|
||||||
public class ReportTextFileVisitor {
|
public class ReportTextFileVisitor {
|
||||||
|
public void visit(INode node){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void visit(IOperation operationBase){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void visit(IChannel channel){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ public class Singleton {
|
|||||||
private static final Singleton instance = new Singleton();
|
private static final Singleton instance = new Singleton();
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private final Map<Class, Object> mapHolder = new HashMap<Class, Object>();
|
private final Map<Class, Object> mapHolder = new HashMap<>();
|
||||||
|
|
||||||
private Singleton() {
|
private Singleton() {
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user