import classifier.gp.*; /** * Defines the function NOT bitwise * * @author Sacchi Matteo, Sassi Federico * @version 0.1 */ public class FunctionNOT extends Function{ /** * inizialize an array of one gprogram containg other function or terminal * */ public FunctionNOT() { arg = new GProgram[1]; } /** * To get the name of the function of the node * @return NOT */ public String getName() { return "NOT"; } /** * Evaluate the program under the node passing an object * @param input the object to evaluale Long or Integer * @return the result of the evaluation as an object */ public Object eval(Object input) { Object value1 = null; try { if (!(LongBox.class.isInstance(input) || LongBoxExt.class.isInstance(input))) { IllegalArgumentException e = new IllegalArgumentException(); throw e; } value1 = arg[0].eval(input); } catch(Exception e) { e.printStackTrace(System.err); System.exit(-1); } ; if(value1.getClass() == LongBoxExt.class) { ((LongBoxExt) value1).longs[0] = (~((LongBoxExt) value1).longs[0]) & 1; return value1; } if(value1.getClass() == LongBox.class) { ((LongBox)value1).long_value = (~((LongBox)value1).long_value) & 1; return value1; } return null; } public long eval(long x) { return ~arg[0].eval(x) & 1; } public double eval(double i) { return 0.0; } public char[] eval(char[] string) { return new String("prova").toCharArray(); } }