CS302 Exam 2 Spring 2013 Reference Solution Part III: Write an instantiable class... import java.util.ArrayList; public class BackPack { private ArrayList items; private String name; private boolean open; //REQUIRED PUBLIC MEMBERS (no additional public members may be added. public BackPack(String name, boolean open) { this.name = name; this.open = open; this.items = new ArrayList(); } @Override public String toString() { String s = name + "'s backpack contains " + items.size() + " items, "; if ( open ) return s + "and is open."; return s + "and is closed."; } public void addItem(String item) { items.add(item); } public void setOpen(boolean open) { this.open = open; } public boolean isOpen() { return open; } public int numItems() { return items.size(); } private String itemAt(int index) { if ( index >=0 && index < items.size() ) return items.get(index); return null; } } // end class BackPack