From ef7a850a8f2f81ccaa07f25d9b7ad602e84d88c9 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Sun, 16 Feb 2014 22:41:46 +0000 Subject: Light refactoring, a good amount of testing done, added some new functions. --- src/jcgp/function/Addition.java | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 src/jcgp/function/Addition.java (limited to 'src/jcgp/function/Addition.java') diff --git a/src/jcgp/function/Addition.java b/src/jcgp/function/Addition.java deleted file mode 100644 index 3a8f123..0000000 --- a/src/jcgp/function/Addition.java +++ /dev/null @@ -1,31 +0,0 @@ -package jcgp.function; - -import jcgp.exceptions.InvalidArgumentsException; -import jcgp.population.Connection; - -public class Addition 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; - } - -} -- cgit v1.2.3