Question
In this lab you will be altering the class from the previous lab to work with Generic ArrayLists, as well as adding one additional method.
In this lab you will be altering the class from the previous lab to work with Generic ArrayLists, as well as adding one additional method.
DataToolsAL.java
http://ge.tt/4Kn7EGn2
Concepts Covered
Use of ArrayLists and Generics
Modifying existing code to work with ArrayLists and Generics
You will need to make changes to the remaining methods such that they no longer take int arrays. Instead they will take Generic ArrayLists so the same method can work with multiple types of data. This will take more than just changing the method headers. The == operator does not work the same for reference types, and should be replaced by using the equals method. Similarly, comparative operators such as <, >, <=, >= will need to be replaced with the use of the compareTo method. Further, the array notation for setting and accessing data will have to be updated to using ArrayList methods. For reference here are links for documentation for https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html
and https://docs.oracle.com/javase/8/docs/api/java/lang/Comparable.html
The documentation for the DataTools class can be found here:
DataToolsAL.pdf
http://ge.tt/9r0nDGn2
A test driver is also provided. Create a new project titled Lab10ArrayListGenerics.
Lab10ArrayListGenerics.java
http://ge.tt/6ckqDGn2
This will perform tests on the methods you write in DataToolsAL. Before running the driver be sure to add your Lab4Packages project to the build path. You can test the algorithms as you write them by commenting out tests for those that you have not completed. Note that the test for the binary search and median requires your Tim Sort to work. This is why the Tim Sort test appears before the binary search and median tests.
Be sure your code conforms to the Checkstyle requirements. You will need to document your Generic type in your javadocs as parameters of methods they appear in. Look to the provided driver to see how this can be done.
The test driver does not take any input. It will generate random data sets to test your searches, sort, and median on. Be sure to look over the output to make sure the results are correct
Lab10ExampleOutput.rtf.dot
http://ge.tt/9hGDEGn2
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