// CSE 143, Winter 2010, Marty Stepp // This client program creates an ArrayIntList object and calls several of // its methods to perform basic testing on the ArrayIntList class. // This second version of the program tests more methods such as remove. public class TestArrayIntList { public static void main(String[] args) { // add 6 elements and print ArrayIntList list = new ArrayIntList(); // 10 // ArrayIntList list = new ArrayIntList(20); // 20 list.add(3); list.add(8); list.add(9); list.add(7); list.add(5); list.add(12); list.print(); System.out.println(); // insert in the middle and print again list.add(3, 42); list.print(); System.out.println(); // insert at the front and print again list.add(0, 999); list.print(); System.out.println(); // add at the end and print again list.add(8, -1); list.print(); System.out.println(); // add more than 10 total elements (resize) and print again list.add(943857); list.add(324768); list.print(); System.out.println(); System.out.println(list.get(18)); System.out.println("index of 42 is " + list.indexOf(42)); System.out.println("index of 12345 is " + list.indexOf(12345)); if (list.isEmpty()) { System.out.println("empty!"); } if (list.contains(42)) { System.out.println("42 is found in the list!"); } System.out.println(); System.out.println("remove tests:"); list.remove(4); list.print(); System.out.println(); list.remove(0); list.print(); System.out.println(); list.remove(list.size() - 1); list.print(); System.out.println(); while (!list.isEmpty()) { list.remove(0); list.print(); System.out.println(); } } }