Question: ** * * This interface will be used to organize and manage test times that are measured for specific operations. * * The user will

** * * This interface will be used to organize and manage test times that are measured for specific operations. * * The user will utilze System.nanoTime() to measure the time it takes to complete an operation. * *
Before the operation is started, you can obtain the start time: * * startTime = System.nanoTime().
* *
After the operation is completed, you can obtain the end time: * * endTime = System.nanoTime().
* *
Run Time is then: * * testTime = endTime - startTime.
* * @author Sameh A. Fakhouri * */ public interface TestTimesInterface { /** * * This method is used to retrieve the last test time. If no test time * has been added, the method will return a zero. * * @return The last test time, in nanoseconds, or zero. * */ public long getLastTestTime(); /** * * This method returns an array of long values representing the last 10 test times. * If less than 10 test times are available, the remaining * test times should be zero. If more than 10 test times have been added, the array * should contain the last 10 test times. * * @return An array of long values representing the last 10 test times. * */ public long[] getTestTimes();
/** * * This method is used to reset all 10 linear search times to zero. * */ public void resetTestTimes();
/** * * This method is used to add a test time. * * @param testTime a long value representing the test time in nanoseconds. * */ public void addTestTime(long testTime); /** * * This method is used to obtain the average test time. The method should average all * the non-zero test times that are available. If no test times are available, the method * returns a zero. * * @return A double value representing the average of all the non-zero test times, or zero. * */ public double getAverageTestTime(); }
/** * * This is a generalized search interface. You will write two classes that implement * this interface: * *
- *
- LinearSearch *
- BinarySearch *
* * @author Sameh A. Fakhouri * */ public interface SearchInterface { /** * * This method is used for searching for a target value in an array * representing a listOfNumbers. * * @param listOfNumbers An array of int values. * * @param target An int value representing the target we are searching for. * * @return If the target value is found, the method will return the index of the * target value in the listOfNumbers. Otherwise, the method will return * -1. * */ public int search(int[] listOfNumbers, int target); }
/** * * These are the methods that you will use to exercise your LinearSearch.java * and BinarySearch classes. * * @author Sameh A. Fakhouri * */ public interface DriverInterface { /** * * This method will generate and return a sorted array of int values * starting at 1 and ending at 10,000,000. * * @return An int array containing the numbers from 1 to 10,000,000. * */ public int[] getListOfNumbers(); /** * * This method will return an int array containing the following values: * *
- *
- 500 *
- 10,000 *
- 100,000 *
- 1,000,000 *
- 5,000,000 *
- 7,500,000 *
- 10,000,000 *
* * @return An int array containing the values specified above. */ public int[] getTargets(); /** * * This method should create an instance of the LinearSearch.java class and * run the search for the specified target in the listOfNumbers * a total of numberOfTimes. * * @param listOfNumbers An int array containing the numbers to search through. * @param target The number we will search for. * @param numberOfTimes The number of times to conduct the search. * * @return The method must return the RunTime class that was used to save the * measured runtimes for the linear searches performed. * */ public TestTimes runLinearSearch(int[] listOfNumbers, int target, int numberOfTimes); /** * * This method should create an instance of the BinarySearch.java class and * run the search for the specified target in the listOfNumbers * a total of numberOfTimes. * * @param listOfNumbers An int array containing the numbers to search through. * @param target The number we will search for. * @param numberOfTimes The number of times to conduct the search. * * @return The method must return the RunTime class that was used to save the * measured runtimes for the binary searches performed. * */ public TestTimes runBinarySearch(int[] listOfNumbers, int target, int numberOfTimes); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
