awt
package are
fillRect
, fillOval
, and fillPolygon
.int[] intValues = {0,1,2};
Disk
ClassDisk
,
to build up and work with disks. The class contains three instance
variables: the x
and
y
coordinates of the center, and the radius.
Instance methods are translate
and draw
for
translating a disk and drawing a disk on the screen.
Disk
class with only the constructors
Disk()
and Disk(int a, int b, int r)
for
creation of the unit disk around the origin and the disk with center
(a
,b
) and radius r
, respectively.translate
and draw
.
Disk
object on the screen.
enlarge
and shrink
,
to double or halve the radius of a disk, respectively. Write an
applet that draws a Disk
object on the screen
together with two buttons to enlarge and shrink the circle.
The applet should look like:
Hint: in the
action(Event evt, Object arg) { ... }
method to
handle the action of pressing one of the buttons, the variable
evt.target
refers to the name of the button actually pressed.
You can compare the value of this variable with the names of your
buttons to find out which button was pressed and what action
should be undertaken.Triangle
, to build up and work with triangles.
The class contains six instance variables: x1
, y1
,
x2
, y2
, x3
, y3
, which are
the x and drawTriangle
and drawMedians
for
drawing a triangle on the screen and for drawing the medians of a
triangle on the screen.
Triangle
class with only the constructor
Triange(int X1, int Y1, int X2, int Y2, int X3, int Y3)
for
creation of a triangle with vertices (X1, Y1)
,
(X2, Y2)
, and
(X3, Y3)
, respectively.drawTriangle
and
write a Java applet that illustrates that everything works as supposed.
drawMedians
that draws the medians of
the current triangle. A median is a line from a vertex of the triangle to
the midpoint of the opposite side. If the vertices have coordinates
(X1
, Y1
),
(X2
, Y2
), and
(X3
, Y3
), then the medians are the lines
connecting
(X1, Y1)
and ((X2+X3)/2, (Y2+Y3)/2)
;(X2, Y2)
and ((X1+X3)/2, (Y1+Y3)/2)
;(X3, Y3)
and ((X1+X2)/2, (Y1+Y2)/2)
.drawMedians
works fine (e.g., do your medians intersect in one point?). The
applet should look like: