// An Applet that demonstrates basic object-oriented design. import java.applet.*; import java.awt.*; import java.util.*; public class LineSegmentCollection extends Applet { Vector theSegments; public void init() { theSegments = new Vector(); for (int i = 0; i < 10; i++) { theSegments.addElement(new LineSegment(i, this)); } } public void paint(Graphics g) { setBackground(Color.red); g.setColor(Color.black); for (Enumeration theEnum = theSegments.elements(); theEnum.hasMoreElements();) { ((LineSegment)theEnum.nextElement()).paint(g); } } public Vector otherSegments(LineSegment oneSegment) { Vector copyOfList = (Vector)(theSegments.clone()); copyOfList.removeElement((Object)oneSegment); return copyOfList; } }