Assignment #2 Instructions

Extend the ArrayIntList class being developed in class and chapter 15 of the book.

You may use the book as a reference but try as much as possible to do the work and create the code on your own. Do NOT just copy the example code from the book!

You may not directly use Arrays class methods ... you must write your own algorithms.

Use the Java reference for the ArrayList class as a guide for definition of desired behavior for methods. The only caveat is we (at this point) are not "growing" the ArrayIntList ... if asked to add an item and the array is at capacity, throw an exception (see 15.2).

Specifically, add the following behavior as methods:

  • ArrayIntList() ... default constructor
  • add(value)
  • get(index)
  • toString()
  • size()
  • indexOf(value)
  • remove(index)
  • add(index, value )
  • ArrayIntList(capacity) ... 2nd constructor taking starting capacity
  • contains(value)
  • isEmpty()
  • set(index, value)
  • clear()
  • addAll(list)

You must make "reasonable" attempts to ensure arguments (indices, capacities) are valid. Create helper methods to handle these checks and throw an appropriate exception if a problem is detected.

Name your new class <your name>_ArrayIntList.java.

Use the provided main program tester to verify your ArrayIntList class is correct.

Your program must EXACTLY match the designated output found in ArrayIntListAssignOutput.txt. Make sure you use the output comparision tool!

Submit the ArrayIntList class source code file to me as usual via DropItToMe

Follow class programming standards and formatting/indentation rules. Make sure you comment your code! In your method headers you must include pre and postconditions.

Assignment Grading

The assignment is worth 35 points.

This is pretty simple...you get 100% if your output exactly matches the expected output...and...0% if it has ANY differences.

Make sure you get all the spelling, capitalization, punctuation, spacing, etc. correct! Hint: copy-n-paste is a wonderful thing! :)