diff options
Diffstat (limited to 'src/jcgp/function/Multiplication.java')
-rw-r--r-- | src/jcgp/function/Multiplication.java | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/src/jcgp/function/Multiplication.java b/src/jcgp/function/Multiplication.java deleted file mode 100644 index 986faa8..0000000 --- a/src/jcgp/function/Multiplication.java +++ /dev/null @@ -1,31 +0,0 @@ -package jcgp.function; - -import jcgp.exceptions.InvalidArgumentsException; -import jcgp.population.Connection; - -public class Multiplication extends Function { - - private int arity = 2; - - @Override - public Object run(Connection... connections) { - if (connections.length < arity) { - throw new InvalidArgumentsException("Not enough connections were given."); - } else if (connections[0].getValue() instanceof Integer) { - Integer arg1 = ((Integer) connections[0].getValue()); - Integer arg2 = ((Integer) connections[1].getValue()); - Integer result = arg1 * arg2; - - System.out.println(arg1 + " * " + arg2 + " = " + result); - return result; - } else { - throw new InvalidArgumentsException("Wrong data type, this function takes Integer."); - } - } - - @Override - public int getArity() { - return arity; - } - -} |