For this assignment you will write a class using composition. You will implement a method that will sort the contents of the array contained in your class as an instance variable. Your sorting method will make use of the insertion sort algorithm and should return the time in milliseconds that it took your algorithm to sort the array (The System class in Java could be useful for this).
Implement the interface provided (following). Your class should have two constructors, a default constructor that uses DEFAULT_MAX_CAPACITY from the interface and a constructor that takes a single integer as a parameter to define the maximum capacity of the array. Additionally, your class should have a method of readFile() for reading the contents of a file (UnsortedNumberFile.txt) and storing the values therein into the array. And then your insertionSort() will sort the numbers in the Array. Afterwards the saveFile() method for storing the contents of the array into the output file. This output file should be named SortedNumberFile.txt and the format should be the same as the input file format (one entry per line).
/*
* SortableArray interface for use in Assignment 1
* Concrete class should have an integer array as an instance variable
* Throw exceptions when user attempts to access indexes less than zero or greater
* than the number of elements.
*/
public interface SortableArrayInterface{
int DEFAULT_MAX_CAPACITY = 1024;
// Returns true if the element was added to the first available position of the array
boolean add(int element);
// Inserts the specified element at the specified position in this list
// Shifts the element currently at that position and any subsequent elements to the right
// Returns true if element added correctly.
// Must observe 0 <= index <= size.
boolean add(int index, int element);
// Returns the element at the specified position in the array
int get(int index);
// Removes and returns the element at the specified position in the array
int remove(int index);
// Returns the number of elements in the array
int size();
// Returns true if able to read and store specified file’s contents into array
boolean readFile(String filename);
// Returns true if able to store array contents into specified file
boolean saveFile(String filename);
// Sort the elements of the array using insertion sort
void insertionSort();
}