Question: Need help creating this class please! Java Eclipse: CompressedArray.java This class represents the array that has been compressed from a matrix (2D array) into a
Need help creating this class please!
Java Eclipse:

CompressedArray.java This class represents the array that has been compressed from a matrix (2D array) into a linear array that excludes elements from the diagonal and any elements above or to the right of the diagonal. Only elements below or to the left of the matrix diagonal must be included in the CompressedArray The class must have the following private variables: origArraySize (int) array (double[]) The class must have the following public methods: public CompressedArray(double(0) [constructor] o Takes in a 2D double array (double(0) which represents the "original array" Initialize the linear double array (instance variable array) and copy the elements from the original array into this linear array so that it contains only the lower-left triangle elements of the original array (the elements to the left and below the diagonal). The elements from this triangle must be added to the CompressedArray in order from left to right and top to bottom. o Hint: Read the description near the top of this document to determine the required capacity for this CompressedArray. public int getLength() o Returns the length of the new, compressed array public double getElement(int) o Returns the element in the new, compressed array stored at the given index public boolean equals(CompressedArray) o Checks equality between the two CompressedArray objects by checking if they have the same length and that all the elements are identical in the same order public String toString() o Builds a string that contains the CompressedArray and formats it in a trianglular structure to look like the lower left corner of a matrix. Each element should take up exactly 8 characters and show 2 decimal places. o Hint: Use String.format("%8.2?", element) for each element and remember to add a newline at the correct places
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
