Question: using blue jay java Programming Projects 509 *P10.5 Declare an interface Filter as follows: public interface Filter { boolean accept(Object x); } Modify the implementation

using blue jay java using blue jay java Programming Projects 509 *P10.5 Declare an interface Filter
as follows: public interface Filter { boolean accept(Object x); } Modify the
implementation of the Data class in Section 10.4 to use both a

Programming Projects 509 *P10.5 Declare an interface Filter as follows: public interface Filter { boolean accept(Object x); } Modify the implementation of the Data class in Section 10.4 to use both a measurer and a Filter object. Only objects that the filter accepts should be processed. Demonstrate your modification by processing a collection of bank accounts, filtering out all accounts with balances less than $1,000. Here is the complete program: section_4/Measurer.java 1 / 2 Describes any class whose objects can measure other objects 37 public interface Measurer St 6 7 Computes the measure of an object. 8 Aparan anbject the object to be measured 9 return the measure 10 */ 11 double measure(Object anobject): 12 er 10 Interfaces section_4/AreaMeasurer.java !import java.awt. Rectangle; 2 3 / 4 Objects of this class measure rectangles by area 5 / 6 public class AreaMeasurer implements Measurer 7 public double measure(Object anobject) 1 TO Rectangle aRectangle - (Rectangle) anbject: double area - aRectangle.getwidth Rectangle.getheight: return area: 13 14 8 9 11 12 section 4/Data.java 1 public class Data 2 3 /* 4 Computer the average of the measures of the given objects 5 Aparan objects an array of objects 6 Oparan meas the measurer for the objects 7 Oreturn the average of the measures / 9 public static double average object objects, Measurer meas) TO 11 double sum - 0: 12 for (object oby: objects) 13 14 Sun - Sun + neas.measure(oby): 15 1 16 if Cobjects.length > 0) { return sun / objects.length; } 17 else { return 0; } 18 19 section_4/Data.java 1 public class Data 2 3 4 Computes the average of the measures of the given objects. 5 Aparan objects an array of objects 6 Oparan neas the measurer for the objects Greturn the average of the measures 8 */ 9 public static double average(Object[] objects, Measurer meas) 10 { 11 double sun-0: for (object obj: objects) 13 Sun - Sun + meas. measure(obj): 15 3 if (objects.length > 0) { return sum / objects.length; } 17 else { return 0; } 19) 14 .16 18 4 section_4/Measurer Tester.java 1 import java.awt.Rectangle: 2 3 / This program demonstrates the use of a Measurer. 5 */ 6 public class Measurer Tester 1 public static void main(String[] args) 10 Measurer areaMeas - new AreaMeasurerO; 11 12 Rectangle rects = new Rectanglet 13 14 new Rectangle(5, 10, 20, 30). new Rectangle(10, 20, 30, 40). 16 new Rectangle(20, 30, 5, 15) 17 }; 7 8 9 15 18 10.5 Inner Class 19 20 21 22 23 ) double averageArea - Data average(rects, areaMeas): System.out.println("Average areas + averageArea); System.out.println("Expected: 625): 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!