class Portfolio extends Asset { private ArrayList myAssets; public static final String INDENT = " "; public Portfolio(String name) { super(name); myAssets = new ArrayList(); } public void add(Asset h) { if (h != this) myAssets.add(h); } private void listAll(String leading) { System.out.println(leading + toString()); for (Asset a : myAssets) { if (a instanceof Portfolio) ((Portfolio) a).listAll(leading + INDENT); else System.out.println(leading + INDENT + a); } } public void listAll() { listAll(""); } @Override public double getValue() { double sum = 0.0; for (Asset a : myAssets) sum += a.getValue(); return sum; } }