import java.util.ArrayList; class Collector { private String name; private ArrayList paintings; int funds; Collector(String name) { this.name = name; this.funds = 100; this.paintings = new ArrayList(); } void inherit(Painting p) { this.paintings.add(p); } void acquire(Painting p) throws TooExpensiveException { if (this.funds < p.getMarketValue()) { throw new TooExpensiveException(); } this.paintings.add(p); this.funds -= p.getMarketValue(); } int getSizeOfCollection() { return this.paintings.size(); } int getFunds() { return this.funds; } void sellTo(Painting p, Collector c) throws TooExpensiveException, NotTheOwnerException { if (c.funds < p.getMarketValue()) { throw new TooExpensiveException(); } if (!this.paintings.contains(p)) { throw new NotTheOwnerException("Not yours!"); } this.paintings.remove(p); c.acquire(p); this.funds += p.getMarketValue(); } public String toString() { return this.name + " ($" + this.funds + ")"; } }