Question: Write a program to demonstrates the concept of inheritance for Square subclass. Consider the requirement below: GeometricFigure class GeometricFigure(): The constructor that sets the height,
- Write a program to demonstrates the concept of inheritance for Square subclass. Consider the requirement below:
GeometricFigure class
- GeometricFigure(): The constructor that sets the height, width and
figureType.
- Display(): A concrete method to display all attributes.
Square subclass:
- Square(): The constructor sets height, width and figureType by calling the superclass constructor.
- DetermineArea(): The method calculates an area of a square: [area = height * width] and call the Display() method from its superclass.
[7 marks]
- Modify Question Q4(a)(ii) by adding an interface called Sides with method printSide () and variable of squareSides with the initial value of 4. Create a program which demonstrates the use of interface Sides in the subclass Square based on the requirement below:
Sides interface:
- printSide(): a declaration of method
- Initializes squareSides variable with the given value of 4.
Square subclass:
- Square(): The constructor sets height, width and figureType by calling the superclass constructor.
- DetermineArea( ) : The method calculates an area of a square: [ area =
height * width ].
- printSide(): Print the number of side of the figure squareSides and call the
Display() method from its superclass.
[8 marks]
answer question b) only
urgent. do in netbean JAVA
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
