Question: Part I Implementing Tuples Python provides the tuple data structure: An immutable sequence that cannot change its size or its contents after it is declared.

 Part I Implementing Tuples Python provides the tuple data structure: An

immutable sequence that cannot change its size or its contents after it

is declared. Java, however, has no equivalent structure. Arrays have a fixed

Part I Implementing Tuples Python provides the tuple data structure: An immutable sequence that cannot change its size or its contents after it is declared. Java, however, has no equivalent structure. Arrays have a fixed size, but their contents can be changed after creation. However, if we wrap an array in an object, we can limit how the array can be accessed. This is the approach we will use to develop our Java tuple implementation You will extend the AbstractList class to create a class called Tuple. Specifically, you must extend , any time that you see E in the Abstract List, API, you can safely say object instead. In addition to those methods, your class must have two public constructors. The first should take no arguments and therefore produce an empty tuple. The second should take an array of Objects as its only parameter. In this constructor, you should copy the contents of the parameter array into the array underlying the tuple Part II Additional Features A close reading of the AbstractList API reveals the following statement: The programmer should generally provide a void (no argument) and collection constructor, as per the recommendation in the collection interface s We created a void constructor in Part I, but we have not yet created a collection constructor. Add a third constructor that takes a Collection as an argument. U a for-each loop to copy items out of the Collection and put them into the tuple Write a new class TupleTest, where you create new instances of Tuples and test their capabilities. Be sure to test this new constructor. Use the API to determine what classes implement the Collection interface that you could use to test this constructor Part I Implementing Tuples Python provides the tuple data structure: An immutable sequence that cannot change its size or its contents after it is declared. Java, however, has no equivalent structure. Arrays have a fixed size, but their contents can be changed after creation. However, if we wrap an array in an object, we can limit how the array can be accessed. This is the approach we will use to develop our Java tuple implementation You will extend the AbstractList class to create a class called Tuple. Specifically, you must extend , any time that you see E in the Abstract List, API, you can safely say object instead. In addition to those methods, your class must have two public constructors. The first should take no arguments and therefore produce an empty tuple. The second should take an array of Objects as its only parameter. In this constructor, you should copy the contents of the parameter array into the array underlying the tuple Part II Additional Features A close reading of the AbstractList API reveals the following statement: The programmer should generally provide a void (no argument) and collection constructor, as per the recommendation in the collection interface s We created a void constructor in Part I, but we have not yet created a collection constructor. Add a third constructor that takes a Collection as an argument. U a for-each loop to copy items out of the Collection and put them into the tuple Write a new class TupleTest, where you create new instances of Tuples and test their capabilities. Be sure to test this new constructor. Use the API to determine what classes implement the Collection interface that you could use to test this constructor

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!