Question
Main Task 1: Modify the ListInterface Java interface we have discussed in class lectures. Sub task 1) change Object to Comparable Note that Comperable is
Main Task 1: Modify the ListInterface Java interface we have discussed in class lectures.
Sub task 1) change Object to Comparable
Note that Comperable is an interface. Objects that inherit from Comperable have a method compareTo(). compareTo() can be used in an algorithm you will have to write for the lab. and at other web pages you can search for.
Sub task 2) change the name of the interface from ListInterface to ComparableListInterface
ListInterface is specified in a PDF file that is linked to below. It is also specified in the textbook for the class. You may use either the PDF file or the textbook to refer to its source code.
Main Task 2: Modify the ListArrayBased class we have discussed in class lectures.
ListArrayBased is also specified in a PDF file that is linked to below. It is also specified in the textbook for the class. You may use either the PDF file or the textbook to refer to its source code. Please note the following corrections to the textbooks source code:
public void add(int index, Object item) throws ListIndexOutOfBoundsException
{
if (numItems >= MAX_LIST) // Use >= instead of >
for (int pos = numItems 1; pos >= index; pos--) // insert 1 after numItems
public void remove(int index) throws ListIndexOutOfBoundsException
{
for (int pos = index + 1; pos ; pos++) //
ListIndexOutOfBoundsException is also specified in a PDF file that is linked to below. It is also specified in the textbook for the class. You may use either the PDF file or the textbook to refer to its source code.
Modify ListArrayBased by performing the following:
1) change the name of the class from ListArrayBased to ComparableListArrayBased
2) change ListInterface to ComparableListInterface
3) change Object to Comparable
4) add a method corresponding to the following UML:
+isInAscendingOrder() : boolean {query}
isInAscendingOrder returns true if the list is in ascending sorted order, else returns false
Test your solution by writing a driver program. The driver program will have a main() method and is the program that is run at the command line. You may give your driver program any name you like. The driver program should perform a loop, ask for input, and display output in the following way (note that the output in bold is what the user inputs):
Input a list of integers: 5 9 101 183 4893
Your list of integers is in ascending order.
Do you want to continue (y): y
Input a list of integers: 5 9 101 183 48
Your list of integers is not in ascending order.
Do you want to continue (y): y
Input a list of integers: 5 4 100 101 183 4893
Your list of integers is not in ascending order.
Do you want to continue (y): y
Input a list of integers: 5 9 101 101 183 4893
Your list of integers is in ascending order.
Do you want to continue (y): y
Input a list of integers: -48 -7 0 5 9 101 183
Your list of integers is in ascending order.
Do you want to continue (y): y
Input a list of integers: 14
Your list of integers is in ascending order.
Do you want to continue (y): y
Input a list of integers:
Your list of integers is in ascending order.
Do you want to continue (y): n
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