Question: Hello I need help with the methods in the class SortedListArrayBased. The instructions for the methods are commented in, I've attached the driver for the

Hello I need help with the methods in the class SortedListArrayBased. The instructions for the methods are commented in, I've attached the driver for the program and also how the results of the program should look. Thank you!

Hello I need help with the methods in the class SortedListArrayBased. The

instructions for the methods are commented in, I've attached the driver for

the program and also how the results of the program should look.

6 public class SortedListDriver { 7 public static void displayList(SortedListInterface list) { 8 // Displays the size and content of the ADT SortedList list 9 // sortedSize() and sortedGet() are tested automatically 10 System.out.println("Size = " + list.sortedSize()); 11 for (int i = 0; i

6 public class SortedListArrayBased implements SortedListInterface { 7 8 // ******************************************************** 9 // Implements SortedListInterface for the ADT list. 10 // ********************************************************* 11 private static final int MAX_LIST = 20; 12 private String items[]; 13 private int numItems; 14 15 public SortedListArrayBased() { 16 items = new String[MAX_LIST]; 17 numItems = 0; 18 } //end default constructor 19 20 public boolean sortedIsEmpty() { 21 // Determines whether a sorted list is empty. 22 // Precondition: None. 23 // Postcondition: Returns true if the list is empty, 24 // otherwise returns false. 25 // Throws: None. 26 return(numItems == 0); 27 } 28 29 public int sortedSize() { 30 // Determines the length of a sorted list. 31 // Precondition: None. 32 // Postcondition: Returns the number of items that are 33 // currently in the list. 34 // Throws: None. 35 return numItems; 36 } 37 38 public void sortedAdd(String item) 39 throws ListException { 40 // Adds an item into its proper sorted position in a sorted list. 41 // Precondition: None. 42 // Postcondition: If insertion is successful, item is at its 43 // proper sorted position in the list, and other items are 44 // renumbered accordingly. 45 // Throws: ListException if item cannot be placed on 46 // the list (list full). 47 48 } 49 public String sortedGet(int index) throws ListIndexOutOfBoundsException{ 50 // Retrieves a sorted list item by position. 51 // Precondition: index is the number of the item to be 52 // retrieved. 53 // Postcondition: If 0 size()-1. 57 return ""; 58 } 59 public void sortedRemove(String item) throws ListException { 60 // Deletes item from a sorted list. 61 // Precondition: None. 62 // Postcondition: If 0 public class SortedListArrayBased implements SortedListInterface { *************** ********* // Implements SortedListInterface for the ADT list. // ************* *********** private static final int MAX_LIST = 20; private String items []; private int numItems; public SortedListArrayBased() { items = new String[MAX_LIST]; numItems = 0; } //end default constructor public boolean sortedIsEmpty() { // Determines whether a sorted list is empty. // Precondition: None. // Postcondition: Returns true if the list is empty, // otherwise returns false. // Throws: None. return(numItems == 0); } public int sortedSize() { // Determines the length of a sorted list. // Precondition: None. // Postcondition: Returns the number of items that are // currently in the list. // Throws: None. return numItems; } public void sortedAdd (String item) throws ListException { // Adds an item into its proper sorted position in a sorted list. // Precondition: None. // Postcondition: If insertion is successful, item is at its Il proper sorted position in the list, and other items are // renumbered accordingly. // Throws: ListException if item cannot be placed on // the list (list full). } public String sortedGet(int index) throws ListIndexOutOfBoundsException{ // Retrieves a sorted list item by position. // Precondition: index is the number of the item to be // retrieved. // Postcondition: If 0 size()-1. return ""; } public void sortedRemove(String item) throws ListException { // Deletes item from a sorted list. // Precondition: None. // Postcondition: If 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!