Iterate over all the Shapes, getting their areas Iterator it = allShapes.iterator(); double total = 0.0; while (it.hasNext()) { Shape s = (Shape)it.next(); total += s.computeArea(); } return total;
Iterator it = allShapes.iterator(); double total = 0.0; while (it.hasNext()) { Shape s = (Shape)it.next(); total += s.computeArea(); } return total;