Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
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...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