Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
public class ListIndexoutOfBoundsException extends IndexOutOfBoundsException f public ListIndexOutofBoundsException (string s) super (s): end constructor y end ListIn dexoutofBoundsException Also, the exception ListException is needed when the array storing the list becomes full. Here is the exception ListException: public class ListException extends RuntimeException f public ListException(String s) t super (s) I/ end constructor // end ListException public class ListIndexoutOfBoundsException extends IndexOutOfBoundsException f public ListIndexOutofBoundsException (string s) super (s): end constructor y end ListIn dexoutofBoundsException Also, the exception ListException is needed when the array storing the list becomes full. Here is the exception ListException: public class ListException extends RuntimeException f public ListException(String s) t super (s) I/ end constructor // end ListException

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

Step: 3

blur-text-image

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

Database Theory And Application Bio Science And Bio Technology International Conferences DTA And BSBT 2011 Held As Part Of The Future Generation In Computer And Information Science 258

Authors: Tai-hoon Kim ,Hojjat Adeli ,Alfredo Cuzzocrea ,Tughrul Arslan ,Yanchun Zhang ,Jianhua Ma ,Kyo-il Chung ,Siti Mariyam ,Xiaofeng Song

2011th Edition

3642271561, 978-3642271564

More Books

Students also viewed these Databases questions

Question

Networking is a two-way street. Discuss this statement.

Answered: 1 week ago