Exercise 10.1 Design the class ArrayAlgorithms. Its member data is an array on Comparable objects. Develop the following methods for this class:
find method which determines whether a given object is one of the elements of this array.
findMinLocation method which returns the index for the smallest item in this array.
floor method which consumes another array of the same size and returns a new array of the same size in which each element is the smaller of the two corresponding elements in the original arrays.
filter method which consumes a Comparable data item and produces a new array which contains only those items from the original array that are smaller that the given item.
sort method which consumes an array of Comparable data items and produces a new array which contains the same elements, but sorted in ascending order.
Write the tests for these methods in the test suite.
Test your code on arrays of Strings and arrays of Integers.
Exercise 10.2 The given code specifies a Double2Double interface and a Plot class. The constructor for the Plot class consumes Rectangle2D object which specifies the region for the display of the function graph. The Plot class also includes the methods plotAxes() which plots the axes for the graph, and plotValue(double x, double y) which plots the value y for the point x.
Write the class FunctionPlot as follows. The member data specify the function to plot - an object in the class which implements the Double2Double interface. Develop the following methods in the class FunctionPlot:
minimum method which consumes the double values x1 and x2 - the two ends of the interval on which the function should be plotted and an int value n which specifies the number of points to plot and returns the minimum value of this function among the n points.
maximum method which consumes the double values x1 and x2 - the two ends of the interval on which the function should be plotted and an int value n which specifies the number of points to plot and returns the maximum value of this function among the n points.
plotFunction method which consumes the double values x1 and x2 - the two ends of the interval on which the function should be plotted and an int value n which specifies the number of points to plot. The function returns void, but displays the graph with axes in the graphics window.
Exercise 10.3 This is an independent continuation of the previous exercise. Develop the method integral which for the given (double) interval (x1, x2) computes the value of the integral of this function, approximated to the value of a given epsilon.