Java Reference
In-Depth Information
public Car(int x, int y)
{
// Remember position
. . .
}
public void draw(Graphics2D g2)
{
// Drawing instructions
. . .
}
}
112
113
Figure 9
The Car Component Draws Two Car Shapes
You will find the complete class definition at the end of this section. The draw
method contains a rather long sequence of instructions for drawing the body, roof,
and tires.
To figure out how to draw a complex shape, make a sketch on graph paper.
The coordinates of the car parts seem a bit arbitrary. To come up with suitable values,
draw the image on graph paper and read off the coordinates ( Figure 10 ).
Search WWH ::




Custom Search