Question
Consider the Flower class: public class Flower{ private double price; public Flower() {price = 2.5;} public Flower(double p) {price = p;} public double getPrice() {return
Consider the Flower class: public class Flower{ private double price; public Flower() {price = 2.5;} public Flower(double p) {price = p;} public double getPrice() {return price;} public void setPrice(double p) {price = p;} public String toString() { return "The price of the flower is $" +price;} public void discount()//20 % basic discount {price *=.80;} }//end of Flower class The Rose class is a subclass of Flower. Write the complete Rose class. The Rose class contains an additional instance variable for the color The Rose class contains a default constructor that: sets the color instance variable to red sets the price instance variable to 2.5 through a call to the super classs default constructor The Rose class contains a constructor that sets the color instance variable to a String parameter sets the price instance variable to a double parameter through a call to the super classs's constructor The Rose class contains two methods getColor/setColor that will get/set the color instance variable The Rose class contains a toString method so that a default rose would print in the following way: The rose is red. The price of the flower is $2.5 The Rose class implements the discount method, returning the cost at a 10% discount.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started