O'Reilly logo

Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition by Ivor Horton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required