/* * Delante Dawkins * I have abided by the UNCG academic integrity policy * 1/27/2014 */ public class dkdawkin_hw1 { public static void main(String[] args) { int[] input; //T[] array = (T[])new Object[5]; Check p= new Prime(); Check ps= new PerfectSquare(); Check n= new Negative(); //boolean result1 = hw1.contains(input,p); //boolean result2 = hw1.contains(input,ps); //boolean result3 = hw1.contains(input,n); } static class hw1 { public boolean contains(T[] input,Checkc) { //Take an array of integers //Checks all elements of an array for the specific Check for(int i=0; i { boolean ok( T item); //item T is ok } static public class Prime implements Check { @Override public boolean ok(Integer val) { for(int i= val/2;i>0; i--) if(val%i!=0 ) return true; return false; } } 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 val) { for(int i= val/2; i>0; i--) if(i*i== val) return true; return false; } } }