February 2014
Beginner
1248 pages
62h 25m
English
Figure 8.17 declares class MyLine, which has all these capabilities. Class MyLine imports classes Color and Graphics (lines 3–4). Lines 8–11 declare instance variables for the coordinates of the endpoints needed to draw a line, and line 12 declares the instance variable that stores the color of the line. The constructor at lines 15–22 takes five parameters, one for each instance variable that it initializes. Method draw at lines 25–29 requires a Graphics object and uses it to draw the line in the proper color and between the endpoints.
Read now
Unlock full access