Java Reference
In-Depth Information
Touch Screen Voting Machine
3.9 Shape Classes
We continue the optional graphics track by discussing how to organize complex
drawings in a more object-oriented fashion. Feel free to skip this section if you are
not interested in graphical applications.
When you produce a drawing that is composed of complex parts, such as the one in
Figure 9 , it is a good idea to make a separate class for each part. Provide a draw
method that draws the shape, and provide a constructor to set the position of the
shape. For example, here is the outline of the Car class.
It is a good idea to make a class for any part of a drawing that that can occur more
than once.
public class Car
{
Search WWH ::




Custom Search