19.10. Exercises

You can download the source code for the examples in the book and the solutions to the following exercises from http://www.wrox.com.

  1. Add code to the Sketcher program to support drawing an ellipse.

  2. Modify the Sketcher program to include a button for switching fill mode on and off.

  3. Extend the classes defining rectangles, circles, and ellipses to support filled shapes.

  4. Extend the curve class to support filled shapes.

  5. Harder—for curve enthusiasts!) Implement an applet to display a curve as multiple CubicCurve2D objects from points on the curve entered by clicking the mouse. The applet should have two buttons—one to clear the window and allow points on the curve to be entered and the other to display the curve. Devise your own scheme for default control points.

  6. (Also harder!) Modify the previous example to ensure that the curve is continuous—this implies that the control points on either side of an interior point, and the interior point itself, should be on a straight line. Allow control points to be dragged with the mouse, but still maintaining the continuity of the curve.

Get Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.