Design, specify, and implement a collection class that is similar to an array of double numbers except

Question:

Design, specify, and implement a collection class that is similar to an array of double numbers except that it automatically grows when wneheedned and negative indexes are also permitted.

The class should include a method to put a double number into the “array” at a specified index. For example, suppose that v is an object of this class. Then v.put(3.8, 7) would put the number 3.8 at index 7 of the “array.” Since negative indexes are also allowed, the statement v.put(9.1, -3) would put the number 9.1 at the index -3.

The class also includes a method to retrieve the number from a specified index. For example, v.get(7) would return the value of the number that is currently at index 7 of the “array.” If a programmer tries to get a value that has not yet been put into the array, then the get method will return the Java constant Double.NaN (which is the way Java represents a double value that is not a real number).

The class should also have two methods that return the value of the largest and the smallest indexes that have ever been set with the put method. If no numbers have yet been put in the “array,” then the “largest” index should be Integer.MIN_VALUE and the “smallest” index should be Integer. MAX_VALUE.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: