Question: The two following classes must iplement the given interface Rotatable and its methods. Class RotatableArray: This class must use an array (NOT an ArrayList) to

The two following classes must iplement the given interface Rotatable and its methods.

Class RotatableArray: This class must use an array (NOT an ArrayList) to store its elements, and the array must grow as necessary to accommodate any number of elements. You are not required to shrink the array, no matter how many elements are removed from the store

Class RotatableStore: This class must not use an array to store its elements, but it must also accommodate any number of elements. Beyond not using an array, you are free to implement this class as you wish.

public interface Rotatable { /** * Removes and returns the leftmost element of the store (which is also removed), * or null if the store is empty. */ E removeLeft(); /** * Removes and returns the rightmost element of the store (which is also removed), * or null if the store is empty. */ E removeRight(); /** * Add an element as the leftmost element of the store. * The previous leftmost element becomes inaccessible. * The size of the store is updated as appropriate. */ void addLeft(E element); /** * Add an element as the rightmost element of the store. * The previous rightmost element becomes inaccessible. * The size of the store is updated as appropriate. */ void addRight(E element); /** * Rotate each element of the store on position to the right. * The rightmost element is removed and reinserted as the leftmost * element. */ void rotateRight(); /** * Rotate each element of the store one position to the left. * The leftmost element is removed and reinserted as the rightmost * element. */ void rotateLeft(); /** * The number of elements currently in the store */ int size();

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!