CS 112 Project 1
Ordered Arrays
Due Friday, Feb. 8th 2008

For your first lab, you will create a Java class OrderedStringArray that manipulates ordered arrays of Strings.  Your class will contain the following public methods:

OrderedStringArray(int initialArraySize,  boolean reversed)
Allocates enough space to store up to initialArraySize elements.  If "reversed" is true, then the list will be sorted in increasing order, of "reversed" is false, then the list will be sorted in decreasing order
int size()
Returns the number of Strings in the list (not the allocated size of the array)
void insert(String element)
Inserts the String "element" into the appropriate location in the sorted array.  If the array is full, create a new array that is twice as large, copy all the old data into the new array, and insert into the new array.  Use the compareTo method on strings to determine where to insert the string.
void delete(int index)
Delete the element at index "index", moving other data in the array as necessar.  Do nothing if the index is outside the bounds of the array
Sring elementAt(int index)
Returns the string at index "index". 
int findFirst(String element)
Returns the index of the frst occurance of the string element, or -1 if no such element exists
boolean inIncreasingOrder()
Returns true if the list is sorted in increasing order
void reverse()
Reverse the order of the list (from increasing to decreasing)
void deleteFirst(String element)
Delete the first element in the array that is equal to "element" (using .equals, not ==)
String toString()
Returns a string representation of the array, which is a "[", followed by all elements in the array separated by ","'s, folllowed by a "]"

Be sure to test all of your methods!


Grading

You will be graded on several criteria:

Program decomposition:  10

Each method should do only one thing: you should have private/protected helper methods so that no one method is too long, or tries to do too many things.

Coding standards 10

Be sure to do proper indentation & commenting

See the Coding Standards for more information

Working

size: 3
insert: (including growing the array): 15
delete:  10
elementAt:  4
findFirst: 10
inIcreasingOrder: 3
reverse (this one is tricky!) 15
deleteFirst: 10
toString (including the empty list, a list with 1 element, and a list of several elements.   Make sure commas are correct!) 10

Submission

All file(s) required for your project should be in the folder https://www.cs.usfca.edu/svn/<username>/cs112/Project1/