Question: please answer question 1 TestTimes class This is the serach and binary interface. the driver interface is also included in the bottom this is the





Details 1. TestTimes Class You will write the TestTimes.java class which will implement the Test Times Interface, The interface may be downloaded from TestTimesInterface.java The Test Times class will contain an array of 10 long values and a counter of how many values have been added using addTestTime(long testTime). Every time a new test time is added, the counter is incremented. 2. Linear Search Class You will write the Linear Search.java class which will inherit from TestTimes.java and implement the Search Interface using a linear search algorithm. The interface may be downloaded from SearchInterface.java Please note that your search method must measure the run time and add it to the TestTimes class by using the addTestTime() method. 3. Binary Search Class You will write the BinarySearch.java class which will inherit from TestTimes.java and implement the Search Interface using a binary search algorithm. The interface may be downloaded from Searchinterface.java Please note that your search method must measure the run time and add it to the TestTimes class by using the addTestTime() method. 4. Driver Class You will write the Driver.java class to test your implementations of 1. TestTimes.java 2. LinearSearch.java 3. BinarySearch.java The Driver.java will implement the Driver Interface. The interface may be downloaded from Driverinterface.java Please note that, in addition to implementing the Driver Interface, you are also required to write your own public static main(String[] args) method in Driver.java that tests all of your classes and methods before submitting your assignment on mimir. Method Detail getLastTestTime long getLastTestTime This method is used to retrieve the last test time. If no test time has been added, the method will return a zero. Returns: The last test time, in nanoseconds, or zero. get TestTimes longll getTestTimes) 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. Returns: An array of long values representing the last 10 test times. reset TestTimes void resetTestTimes() This method is used to reset all 10 linear search times to zero. addTestTime void addTestTime( long testTime) This method is used to add a test time. Parameters: testTime - a long value representing the test time in nanoseconds. getAverage TestTime double getAverage 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. Returns: A double value representing the average of all the non-zero test times, or zero. All Known Implementing Classes: BinarySearch, Linear Search public interface SearchInterface This is a generalized search interface. You will write two classes that implement this interface: 1. Linear Search 2. BinarySearch Author: Sameh A. Fakhouri Method Summary All Methods Instance Methods Abstract Methods Modifier and Type Method and Description int search(int[] listOfNumbers, int target) This method is used for searching for a target value in an array representing a listOfNumbers Method Detail search int search(int[] listOfNumbers, int target) This method is used for searching for a target value in an array representing a listOfNumbers. Parameters: listOfNumbers - An array of int values. target - An int value representing the target we are searching for. Returns: If the target value is found, the method will return the index of the target value in the list of Numbers. Otherwise, the method will return -1. 5:07 PM Thu Jan 28 @ 24% class website PACKAGE CLASS USE TREE DEPRECATED INDEX HELP PREV CLASS NEXT CLASS FRAMES NO FRAMES ALL CLASSES SUMMARY: NESTED | FIELD CONSTRI METHOD DETAIL FIELD CONSTR METHOD Interface Driverinterface All Known Implementing Classes: Driver public interface Driver Interface These are the methods that you will use to exercise your Linear Search.java and BinarySearch classes, Author: Sameh A. Fakhouri Method Summary All Methods Instance Methods Abstract Methods Modifier and Type Method and Description int! getListOfNumbers() This method will generate and return a sorted array of int values starting at 1 and ending at 10,000,000 int getTargets() 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 TestTimes runBinarySearch(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 list ofNumbers a total of numberOfTimes. TestTimes runLinear Search(int) listofnumbers, int target, int numberOfTimes) 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. 5:07 PM Thu Jan 28 @ 24% class website PACKAGE CLASS USE TREE DEPRECATED INDEX HELP PREV CLASS NEXT CLASS FRAMES NO FRAMES ALL CLASSES SUMMARY: NESTED | FIELD CONSTRI METHOD DETAIL FIELD CONSTR METHOD Interface Driverinterface All Known Implementing Classes: Driver public interface Driver Interface These are the methods that you will use to exercise your Linear Search.java and BinarySearch classes, Author: Sameh A. Fakhouri Method Summary All Methods Instance Methods Abstract Methods Modifier and Type Method and Description int! getListOfNumbers() This method will generate and return a sorted array of int values starting at 1 and ending at 10,000,000 int getTargets() 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 TestTimes runBinarySearch(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 list ofNumbers a total of numberOfTimes. TestTimes runLinear Search(int) listofnumbers, int target, int numberOfTimes) 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. 5:07 PM Thu Jan 28 @ 24% class website Method Detail getListOlNumbers int[getListOfNumbers() This method will generate and return a sorted array of int values starting at 1 and ending at 10,000,000 Returns: An int array containing the numbers from 1 to 10,000,000. getTargets int[] getTargets() This method will return an int array containing the following values: 1.500 2. 10,000 3. 100,000 4. 1,000,000 5. 5.000.000 6. 7.500,000 7. 10,000,000 Returns: An int array containing the values specified above. runLinear Search TestTimes runLinear Search(int II listofnumbers, int target, int numberOfTimes) This method should create an instance of the Linear Search.java class and run the search for the specified target in the listOfNumbers a total of numberOfTimes. Parameters: listOfNumbers - An int array containing the numbers to search through. target - The number we will search for. numberOfTimes - The number of times to conduct the search. Returns: The method must return the TestTimes class that was used to save the measured test times for the linear searches performed. 5:07 PM Thu Jan 28 @ 24% class website Returns: An int array containing the values specified above. runLinear Search TestTimes runLinear Search(int[] listofnumbers, int target, int numberOfTimes) This method should create an instance of the Linear Search.java class and run the search for the specified target in the listofnumbers a total of numberOfTimes. Parameters: listOfNumbers - An int array containing the numbers to search through. target - The number we will search for. numberOfTimes - The number of times to conduct the search. Returns: The method must return the TestTimes class that was used to save the measured test times for the linear searches performed. runBinary Search TestTimes runBinarySearch(int[] tistofNumbers, 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 list ofNumbers a total of number of Times. Parameters: listOfNumbers - An int array containing the numbers to search through. target - The number we will search for. numberOfTimes - The number of times to conduct the search. Returns: The method must return the TestTimes class that was used to save the measured test times for the binary searches performed. PACKAGE CLASS USE TREE DEPRECATED INDEX HELP PREV CLASS NEXT CLASS FRAMES NO FRAMES ALL CLASSES SUMMARY: NESTED FIELD I CONSTRI METHOD DETAIL FIELD CONSTR | METHOD 1:24 AM Fri Jan 29 @ 61% X SUMMARY. NESTED, FIELD CONSTRI METHOD Interface TestTimesInterface class website DETAIL FIELD I CONSTRI METHOD All known Implementing Classes: BinarySearch, Linear Search, TestTimes public interface TestTimes Interface 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(). Test Time is then: testTime = endTime - StartTime. Author: Sameh A. Fakhouri Method Summary All Methods Instance Methods Abstract Methods Modifier and Type Method and Description void addTestTime(long testTime) This method is used to add a test time. double getAverageTestTime() This method is used to obtain the average test time, long getLastTestTime() This method is used to retrieve the last test time. long getTestTimes() This method returns an array of long values representing the last 10 test times. resetTestTimes() This method is used to reset all to linear search times to zero. void 1:25 AM Fri Jan 29 @ 61% class website Method Detail getLastTestTime tong getLastTestTime() This method is used to retrieve the last test time. If no test time has been added, the method will return a zero. Returns: The last test time, in nanoseconds, or zero. getTest Times longt) getTestTimes) 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. Returns An array of long values representing the last 10 test times. reset TestTimes void resetTestTimes) This method is used to reset all 10 linear search times to zero. addTestTime void addTestTime(long testTime) This method is used to add a test time Parameters: testTime - a long value representing the test time in nanoseconds. getAverage TestTime double getAverage 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. Returns: A double value representing the average of all the non-zero test times, or zero
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
