Question: I need help with constructor declaration. I have a class called flower which has the following parameters: //constructor that accepts 3 colors public flower (Color

I need help with constructor declaration. I have a class called flower which has the following parameters:

//constructor that accepts 3 colors

public flower (Color tulip, Color rose, Color daisy)

{ this.tulip = tulip; this.rose = rose; this.daisy = daisy; }

If I want to make a class called garden, and want to make an instance of flower class: what constructor do I use to create a new object flower in the garden class?

Is this right? If not how do I do it?

flower = new flower(tulip, rose, daisy);

Note: I do not need output for this question.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!