create a program that models different types of flowers using an abstract class. You will define an
Fantastic news! We've Found the answer you've been seeking!
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 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.
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date: