Java Reference
In-Depth Information
(a)
(b)
(c) (d) (e)
F IGURE 13.34 (a) The program displays an arrow line. (b-c) Exercise13.29 connects the centers of two filled circles.
(d-e) Exercise13.30 connects two circles from their perimeter.
*13.30
( Connect two circles ) Write a program that draws two filled circles with radius 15
pixels, centered at random locations, with a line connecting the two circles. The
line should not cross inside the circles, as shown in Figure 13.34d-e. When you
resize the frame, the circles are redisplayed in new random locations.
*13.31
( Geometry: Inside a polygon? ) Write a program that passes the coordinates of five
points from the command line as follows:
java Exercise13_31 x1 y1 x2 y2 x3 y3 x4 y4 x5 y5
The first four points form a polygon, and the program displays the polygon in a
panel and a message in a label that indicates whether the fifth point is inside the
polygon, as shown in Figure 13.35a.
(a)
(b)
(c)
(d)
F IGURE 13.35
(a) The polygon and a point are displayed. (b-d) Two rectangles are
displayed.
Search WWH ::




Custom Search