213k views
0 votes
Java’s class Color has a constructor that takes three integers as parameters: the red, green, and blue components of the color. A class Balloon has two fields: double radius and Color color. Write a constructor for the Balloon class that takes no parameters and sets the balloon’s radius to 10 and its color to "sky blue" (with RGB values 135, 206, and 250).

1 Answer

4 votes

Answer:

public Balloon () {

this.radius = 10;

this.color = new Color(135,206,250);

}

Step-by-step explanation:

To solve this problem you need to use the constructor from the Color class to create an object with the sky blue RGB ints (Dont forget import the Color class)

class Balloon

{

private double radius;

private Color color;

public Balloon() {

this.radius =10;

this.color = new Color(135,206,250);

}

}

User Edwindj
by
5.1k points