Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

image text in transcribed

image text in transcribed

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

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_2

Step: 3

blur-text-image_3

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

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago