Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In java, redo the following program by creating and adding a Class called OrderedArrayList . This class will include a method to sort an array.
In java,
redo the following program by creating and adding a Class called OrderedArrayList. This class will include a method to sort an array. The datatype of the values within the array will be of type DataElement.
- Then create and name the Class "OrderedArrayList" and make sure it extends UnorderedArrayList.
- You will want the same constructors as UnorderedArrayList (only these are for OrderedArrayList).
- Place the method to sort the array in this Class.
- Remember - the datatype here is DataElement!! This means that this class will work for both integers AND strings.DO NOT add any other methods to this Class. It should only contain the sort method.
- So when you swap elements in the array and need a temporary variable to store a value then that value will be of typeDataElement!
- In your Driver, instantiate an array of type OrderedArrayList. In your Driver, with the array you instantiated in step 2, use dot notation to call the sorting method.Then, print out the array to verify that it is sorted.
- Remove the instantiation of UnorderedArrayList array. You will only use the instantiated object of OrderedArrayList array.BecauseOrderedArrayList extends UnorderedArrayList, you also get to use all of the methods within UnorderedArrayList. You don't need to copy any into OrderedArrayList. Because UnorderedArrayList extends ArrayListClass, you also get to use all of the methods within ArrayListClass.To access any method - no matter which of the three classes the method belongs to, just use the same dot notation as shown in Example3_1.
- Change all of the calls using the UnorderedArrayList array name to the OrderedArrayList array name.
- There should be NO instantiated arrays of UnorderedArrayList in the Driver.
- Remove the instantiation of UnorderedArrayList array. You will only use the instantiated object of OrderedArrayList array.BecauseOrderedArrayList extends UnorderedArrayList, you also get to use all of the methods within UnorderedArrayList. You don't need to copy any into OrderedArrayList. Because UnorderedArrayList extends ArrayListClass, you also get to use all of the methods within ArrayListClass.To access any method - no matter which of the three classes the method belongs to, just use the same dot notation as shown in Example3_1.
- Using this same array, call all of the methods from the original Example3_1 program.
- You should find that everything works the same.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started