Question: Please finish these two questions! 4. Write a method max with three arguments that finds the larger of any two objects, using a Measurer to

Please finish these two questions!
4. Write a method max with three arguments that finds the larger of any two objects, using a Measurer to compare them. Data.java 1 public class Data 3 1* Computes the largest of two given objects @param a the first object aparam b the second object @param meas the Measurer for these objects @return the largest of the two objects 10 public static Object max( a, meas) 12 13 DataTester.java 1 public class DataTester 3 public static void main(String[] args) Measurer strMeas new StringMeasurer); System.out.println (Data.max("cat", "book", strMeas)); System.out.println("Expected: book"); System.out.println (Data.max("penquin", "pequot", strMeas)); System.out.println("Expected: penquin"); 10 CodeCheck Reset 5.Write a call to the maxmethod of the preceding exercise that computes the larger of two rectangles, then prints its width and height. MeasurerDemo.java 1 import java.awt.Rectangle; 2 public class MeasurerDemo 4 public static void main(String[] args) Measurer areaMeas new AreaMeasurer; Rectangle rl new Rectangle(5, 1e, 20, 30); Rectangle r2new Rectangle (1, 20, 30, 40) 10 Rectangle largest.. 12 13 14 15 System.out.println("Width "largest.getwidth)) System.out.println("Height: largest.getHeight)) AreaMeasurer.java 1 import java.awt.Rectangle; 4 Objects of this class measure rectangles by area 6 public class AreaMeasurer implements Measurer 8 public double measure(0bject anobject) 10 12 Rectangle aRectangle (Rectangle) anobject; double areaaRectangle.getwidth aRectangle.getHeight; return area; 13 CodeCheck Reset
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
