// Erika Wolfe // Sample client code that manipulates two ArrayIntList objects. // This is an example of simple tests you can write for your // assignments. Note that this uses more descriptive print // statements than in lecture. This makes output easier to read! public class ArrayIntListClient { public static void main(String[] args) { // create two ArrayIntLists ArrayIntList list1 = new ArrayIntList(); ArrayIntList list2 = new ArrayIntList(); // add 20, 27, 43, 19 to list1 list1.add(20); list1.add(27); list1.add(43); // adding at size is the same as the appending add list1.add(list1.size(), 19); list1.add(2, 4); System.out.println("initial list1: " + list1); list2.add(1); list2.add(16); System.out.println("initial list2: " + list2); System.out.println(); // change index 2 to 17 list1.set(2, 17); System.out.println("list1 after set(2, 17): " + list1); // add all elements from list2 into list1 list1.addAll(list2); System.out.println("list1 after addAll(list2): " + list1); list1.remove(2); System.out.println("list1 after remove(2): " + list1); System.out.println(); ////////////// // Some sample tests additional to those discussed in lecture ////////////// System.out.println("list1.indexOf(20) - should be 0: " + list1.indexOf(20)); // remove at the front and the end list1.remove(0); list1.remove(list1.size() - 1); System.out.println("list1 after remove calls: " + list1); // testing size() and contains after remove() System.out.println("list1 size - should be 4: " + list1.size()); System.out.println("list1.contains(20) - should be false: " + list1.contains(20)); // more tests here :) } }