ArrayPriorityList



Project SortableList

Collaboration: Complete by yourself with help from section leaders and Rick

Preview: This project asks you to implement a collection class SortableList using an array instance variable. This project has the following goals:

• Implement a collection class using an array data structure

• Understand how generic classes store collections of the same type element safely

• Implement and understand the insertion sort algorithm plus some other array processing algorithms

Begin a new Java project in Eclipse and get these three files into the src folder. There should be no compile-time errors and the test methods should not pass:

1. SortableList.java

2. SortableListTest.java

SortableList

/**

* @author [YOUR NAME]

*

* @param

* The generic argument that states what type of data this SortableList

* will hold.

*/

public class SortableList {

private Object[] elements;

private boolean isSorted;

private int size;

/**

* Create a new Object array of capacity 20 (MUST BE 20), set the size to

* zero, and set isSorted to false;

*/

public SortableList() {

}

/**

* Adds the passed element at index size (at the end of the list) to the

* array. Will grow the array if necessary.

*

* If adding the next value ruins the sort the array, set isSorted to false

*

* @param data

* The element being added at the 'end' of this SortableList, at

* index size()

*/

public void add(E data) {

}

/**

* Returns the data at the given index.

*

* @param index The location of the element.

* @return The element at the given index or null if there isn't data at the

* given index

* Precondition: 0 ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download