1. Engineering
  2. Computer Science
  3. need help with code homework please code is down below...

Question: need help with code homework please code is down below...

Question details

Need help with code homework please (Code is down below)

Prompt:   

Note: the sort() method needs to return an array, it is not void.

Your task is to implement the provided interface
that uses a generic type.

To implement the interface, you must code a class that
overrides all the methods specified in the interface.
When you open the provided interface code, you will
see documentation I wrote that explains what each method
needs to do. You heading for your class should be

public class ArrayFunctions<T> implements ArrayFunctionsInterface<T>

Once you have written your implementing class, write two driver classes
to test each method. In one class, have the T represent the Integer type.
For the second driver class have the T represent the String type.

In both drivers, test each method. Here is an example of how you
would demonstrate your testing.

System.out.println(Here is the original array: ");
System.out.println(myArray.printtMe( ));
System,out.println("Here is a test of sort: ");
System.out.println(myArray.sortMe( ).printMe( ));

Be sure you code is well documented with javadocs, inline
comments, meaningful names. All class names beging with an
uppercase letter and all fields and variables use camelCase.

Coding conventions and documentation:

Conventions:  All class names begin with an uppercase letter  All field and local variable names use camelCase.  All constant fields are names using all CAPS  Names of fields, local variables, parameters, methods must be meaningful

Coding:  Do not use a break statement to get out of a loop  Do not use a continue statement to skip an iteration of a loop  A method should have only one return statement, not many  Never code loop with this heading: while(true)

Documentation:  Meaningful names for identifiers  Javadoc comments on top of the class and on top of each method o @author o @version o @overrides o @param (if the method takes arguments) o @return (if the method returns a value)  Good use of explanatory in-line comments

CODE:


/**
* An interface contains only public method headers.
* If there are any fields they must be public, static and final.
* They are used for design and for the is-a relationship
* in inheritace.
*
* A programmer implements an interface by overriding all
* the methods specifed in the interface. That means the
* programmer must write the code in a separate class file for each and
* every method specified in the interface.
*
* Your task is to write all the method bodies in a separate
* class named ArrayFunctions. This will be your class header:
*
* public class ArrayFunctions<T> implements ArrayFunctionsInterface<T>
*
*
* @author (your name)
* @version (a version number or a date)
*/
public interface ArrayFunctionsInterface<T>
{
/** This method copies contents of the original array into a
* new array and then sorts this new array. A reference to the
* new array is returned. You are to write your own sort method
* and call the compareTo( ) method in your sort code.
*/
T[ ] sortMe(T [ ] inArray);

/** This method accepts a reference to an array and
* returns a reference to the maximum element of the
* array. The maximum is found by calling the compareTo( ) method
*/
T getMax(T [ ] array);
  
/** This method accepts a reference to an array and
* returns a reference to the minimum element of the
* array. The maximum is found by calling the compareTo( ) method
*/
T getMin(T [ ] array);
  
/** This method accepts a reference to an array and a reference to
* an object to search for. If the object is not in
* the array, retrun a -1. You use the equals( ) method
* in the search.
*/
int whereAmI(T [ ] array, T searchValue);
  
/** This method copies contents of the original array into a
* new array in reverse order.
*/
   T[ ] reverseMe(T [ ] array);
  
   /** This method prints the contents of the array to
   * the screen. This method calls the toString( ) method.
   */
void printMe(T [ ] array);
  
/** This method copies contents of the original array into a
* new array that is double the capacity of the original array.
* The contents of the original array are copied to the new array.
* The extra elements will automatically be assigned a value of null
* A reference to the new array is returned.
*/
T[ ] doubleMyCapacity(T [ ] array);

}
  

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution