Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

Identify the elements that make up the employee reward package.

Answered: 1 week ago

Question

Understand the purpose, value and drawbacks of the interview.

Answered: 1 week ago