Question
Create a new Java project called usernamePart4 in NetBeans. Select the option to create a main method. Create a new class called Flower. Create a
Create a new Java project called usernamePart4 in NetBeans. Select the option to create a main method. Create a new class called Flower. Create a new interface called Plant. Rewrite your code from Part 2 so that: Plant is an interface Flower implements Plant 4 The Plant interface contains at least 2 abstract methods All methods, constructors and instance variables that were in the Flower and Plant classes in part 2 must be included in part 4. You need to rewrite the Flower and Plant classes from part 2 so that Plant is an interface and there are multiple ways to create a Flower. In the main method of your project write the code to: Declare a Stack with a type parameter of Flower Add at least 3 Flowers to the Stack Demonstrate the use of: o peek() o pop() o empty()
PART 2:
Create a new Java project called usernamePart2 in NetBeans. Select the option to create a main method. Create a new class called Flower. Create a second class called Plant. Copy the code from the Plant class you created in Part 1 into the new Plant class. Modify the new Flower class so that it extends Plant (Plant is the superclass, Flower is the subclass). In the Flower class write the code for: 2 instance variables that are appropriate for a Flower Accessor and mutator methods for the 2 instance variables A default constructor and a second constructor that initialises all the instance variables in the Flower and the Plant classes using the super keyword The Flower class must also demonstrate the use of: Overloaded methods Overriding a method and the super keyword in a method 3 Polymorphism In the class that contains the main method, create a second method that takes a Plant as a parameter and uses one of the plants accessor methods. Then create an object of type Flower and an object of type Plant in the main method and use the method you have just created to demonstrate polymorphism.
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