Filter generic interface declaring single method


Assignment:

Write each of the given classes. You also need to write a Driver class to test the classes and methods.

Question 1: Write a Filter class named IsPositive which has the given features.

a) A constructor which accepts no arguments.

b) The accepts method will operate only on Integer objects and accept any Integer which is positive.

Question 2: Write a Filter class named SimilarColor which has the given features.

a) A constructor which accepts a Color object known as the reference color.

b) The accepts method will operate only on objects of Color type. It will return true if the specified color is identical to the reference color. Two colors are similar if the sum of the absolute differences in red, green and blue are less than 5.

Question 3: Write a Filter class named StartsWith that has the given features.

a) A constructor which accepts a String object termed as the reference string.

b) The accepts method will operate only on Strings. It will accept any string object which begins with the reference string.

Question 4: Write a Filter class named LessThan which has the given features.

a) A constructor which accepts the reference object. The reference object should be a subclass of Comparable.

b) The accepts method will operate only on objects of the type specified in the constructor and will return true only if the input object is less than the reference object.

Question 5: Write a Filter class named Subset which has the given features.

a) A constructor which accepts a java.util.List objects termed as the reference list.

b) The accepts method will operate only on lists of the same type as the reference list. The method will only accepts a list if each of its elements is contained in the reference list.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Filter generic interface declaring single method
Reference No:- TGS03117

Expected delivery within 24 Hours