Question: create a program that models different types of flowers using an abstract class. You will define an abstract class named Flower and create concrete subclasses
- create a program that models different types of flowers using an abstract class. You will define an abstract class named Flower and create concrete subclasses for different flower types.
- Create an abstract class named Flower with the following abstract methods:
- abstract String getColor() to get the color of the flower.
- abstract String getSpecies() to get the species of the flower.
- abstract double getPrice() to get the price of the flower.
- Create concrete subclasses for different flower types:
- Rose: This class should extend Flower and have a constructor that takes the color, species, and price as parameters.
- Tulip: This class should extend Flower and have a constructor that takes the color, species, and price as parameters.
- Daisy: This class should extend Flower and have a constructor that takes the color, species, and price as parameters.
- In each flower subclass, implement the abstract methods (getColor(), getSpecies(), and getPrice()) to return the corresponding properties of the flower.
In the main method of your FlowerTest class, create instances of each flower type (e.g., a rose, tulip, and daisy) with different colors, species, and prices. Then, display the details of each flower.
Step by Step Solution
There are 3 Steps involved in it
Heres a Java program that models different types of flowers using an abstract class Flower and concrete subclasses for Rose Tulip and Daisy java abstr... View full answer
Get step-by-step solutions from verified subject matter experts
