public class MyArrayCollection implements Collection { final int CAPACITY = 9; protected int size; protected int [] array = new int[CAPACITY]; public boolean add(Integer x) { if (size == CAPACITY) { return false; } else { array[size] = x; size++; return true; } } public boolean addAll(Collection c) { if (size == CAPACITY) { return false; } else { for (Integer x: c) { if (size < CAPACITY) { this.add(x); size++; } else { break; } } } return true; } public void clear() { size = 0; } public boolean contains(Object o) { boolean pr = false; if (size == 0) { pr = false; } else { for (Object i : array) { if (i == o) { pr = true; break; } } } return pr; } public boolean containsAll(Collection c) { boolean pr = true; if (size < c.size()) { pr = false; } else { for (Object x : c) { if (!this.contains(x)) { pr = false; break; } } } return pr; } public boolean equals(Object o) { return this.equals(o); } public int hashCode() { return 0; } public boolean isEmpty() { if (size == 0) { return true; } else { return false; } } public Iterator iterator() { return null; } public boolean remove(Object o) { boolean pr = false; if (size == 0) { pr = false; } else { if (this.contains(o)) { size--; pr = true; } } return pr; } public boolean removeAll(Collection c) { boolean pr = false; if (size == 0) { pr = false; } else { for (Object x: c) { if (this.contains(x)) { this.remove(x); size--; pr = true; } } } return pr; } public boolean retainAll(Collection c) { boolean pr = false; if (size == 0) { pr = false; } else { for (int i: this) { if (!c.contains(i)) { this.remove(i); size--; pr = true; } } } return pr; } public int size() { return size; } public Object[] toArray() { return null; } public T[] toArray(T[] a) { return null; }