From 2bf2d3ac2c578de481ecfd545d58be73c5628996 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Wed, 26 Mar 2014 21:34:37 +0000 Subject: Node grid has been refactored a few times, settings pane is almost complete, console is all done. --- src/jcgp/function/FunctionSet.java | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/jcgp/function') diff --git a/src/jcgp/function/FunctionSet.java b/src/jcgp/function/FunctionSet.java index 07b4ea4..49ff7e7 100644 --- a/src/jcgp/function/FunctionSet.java +++ b/src/jcgp/function/FunctionSet.java @@ -3,6 +3,7 @@ package jcgp.function; import java.util.ArrayList; import java.util.Iterator; + /** * * @author Eduardo Pedroni @@ -14,14 +15,14 @@ public abstract class FunctionSet { protected int maxArity; protected String name; -// public int getTotalFunctionCount() { -// return functionList.length; -// } - - public int getFunctionCount() { + public int getAllowedFunctionCount() { return allowedFunctions.size(); } + public int getTotalFunctionCount() { + return functionList.length; + } + public Function getFunction(int index) { return allowedFunctions.get(index); } @@ -35,14 +36,15 @@ public abstract class FunctionSet { } public void disableFunction(int index) { - for (Iterator iterator = allowedFunctions.iterator(); iterator.hasNext();) { - if (index < functionList.length) { + if (index < functionList.length) { + for (Iterator iterator = allowedFunctions.iterator(); iterator.hasNext();) { Function function = (Function) iterator.next(); if (function == functionList[index]) { iterator.remove(); } } - + } else { + throw new IndexOutOfBoundsException("Function " + index + " does not exist, the set only has " + functionList.length + " functions."); } } @@ -51,4 +53,9 @@ public abstract class FunctionSet { allowedFunctions.add(functionList[index]); } } + + @Override + public String toString() { + return name; + } } \ No newline at end of file -- cgit v1.2.3