//package homework1; //author Kyle Fields public class kkfields_hwk1 { public static boolean contains(T[] input, Check c) { int i = 0; while(i { boolean ok( T item); //item T is ok (negative e.g.) } static public class Negative implements Check { @Override public boolean ok( Integer val) { return val < 0; } } static public class PerfectSquare implements Check { @Override public boolean ok(Integer i) { long SquareRoot = (long) Math.sqrt(i); //multiplys the sqrt by the sqrt to see if it equals the original if (((SquareRoot * SquareRoot) == i) == true){ return true; } return false; } } static public class Prime implements Check { @Override public boolean ok(Integer n) { if (n >= 2) { if (n == 2) { return true; } for (int i = 2; i <= Math.sqrt(n) + 1; i++) { if (!(n % i == 0)) { return true; } } } return false; } } public static void main(String[] args) { } }