spec2 - CSE 143 Winter 2010 Programming Assignment#2...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 of 4 CSE 143, Winter 2010 Programming Assignment #2: SortedIntList (20 points) Due Thursday, January 21, 2010, 11:30 PM This program focuses on implementing a collection and inheritance. Turn in two files named SortedIntList.java and MyListTest.java from the Homework section of the course web site. You will also need the support file ArrayIntList.java from the Homework section of the course web site; place it in the same folder as your program. For this assignment you are to write a class called SortedIntList that is a variation of the ArrayIntList class written in lecture. Your class will be an extension (a subclass) of the original ArrayIntList that adds new functionality and modifies some existing functionality. Your class has two primary differences from the original list: A SortedIntList must maintain its list of integers in sorted (non-decreasing) order. A SortedIntList has an option to specify that the numbers should be unique (no duplicates). The ArrayIntList class already has the following constructors and methods (along with a few others): public ArrayIntList() constructs an empty list of a default capacity (10) public ArrayIntList(int capacity) constructs an empty list with given capacity public void add(int value) appends given value to end of list public void add(int index, int value) inserts given value at given index, shifting subsequent values right public int get(int index) returns the element at the given index public int indexOf(int value) returns index of first occurrence of given value (< 0 if not found) public void remove(int index) removes value at given index, shifting subsequent values left public int size() returns current number of elements in the list public String toString() returns a string version of the list, such as "[4, 5, 17]" The new class should extend ArrayIntList , adding a few new methods and constructors, and overriding some existing methods to improve their functionality. You should not modify the contents of ArrayIntList.java in any way; if your code does not work with the provided ArrayIntList.java , you will lose points. You will add the following: public SortedIntList () constructs an empty list of a default capacity, allowing duplicates public SortedIntList (boolean unique) constructs empty list of default capacity and given "unique" setting public SortedIntList (int capacity) constructs an empty list with given capacity, allowing duplicates public SortedIntList ( boolean unique, int capacity) constructs an empty list with given capacity and "unique" setting public void add (int value) possibly adds given value to list, maintaining sorted order public void add (int index, int value) possibly adds given value to list, maintaining sorted order public boolean getUnique () returns whether only unique values are allowed in the list public int indexOf (int value) returns index of an occurrence of the given value (< 0 if not found) public int max () returns the maximum integer value stored in the list
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/04/2011 for the course CSE 143 taught by Professor Sr during the Spring '08 term at University of Washington.

Page1 / 4

spec2 - CSE 143 Winter 2010 Programming Assignment#2...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online