EX 7.8 Overload the drawCircle method of Exercise 7.6 such that if the
radius is not provided, a random radius in the range 10 to 100
(inclusive) will be used.
Ans
public void drawCircle (Graphics page, int x, int y,
Color shade)
{
int radius = (int) (Math.random()*91) + 10;
page.setColor (shade);
page.drawOval (x-radius, y-radius, radius*2,
radius*2);
}
EX 7.9 Overload the drawCircle method of Exercise 7.6 such that if
both the color and the radius of the circle are not provided, the
color will default to red and the radius will default to 40.
Ans
public void drawCircle (Graphics page, int x, int y)
{
page.setColor (Color.red);
page.drawOval (x-radius, y-radius, 80, 80);
}
EX 7.10 Discuss the manner in which Java passes parameters to a
Share with your friends: |