Question: How do you acomplish this assignment? Assignment Inheritance CSIS-1410 Learning Objectives Declare a subclass that derives from a superclass Demonstrate polymorphic behavior Declare a variable



How do you acomplish this assignment?
Assignment Inheritance CSIS-1410 Learning Objectives Declare a subclass that derives from a superclass Demonstrate polymorphic behavior Declare a variable of the superclass type and assign it an instance of the subclass type Access the public members of the superclass type Notice how the overridden versions of the subclass type are called Notice how the subclass specific members are inaccessible Create an array of superclass type and use a foreach loop to iterate through it Style /Comments: On this and all upcoming assignments pay attention to style. Follow Java naming convention, use proper indentation, group related code statements with single empty lines, use descriptive names etc. Strive to write code that is clear and easy to read Also: use doc comments on all your code Description Write a program to demonstrate the use of inheritance and polymorphism You will create 4 classes: Rectangle, Square, IsoscelesRightTriangle, and Circle In addition you will create a class called InheritanceApp. This class includes the main method. Here we test the four other classes and we demonstrate the polymorphic behavior Declare the classes as described below: Class Retangle . Rectangle has 2 private final fields of type int: length and width . It has (exactly) one parameterized constructor that initializes both fields It provides a getter (get accessor method) for each of the fields (no setter) It overrides the toString method so that it produces a result of the form Rectangle (lengthxwidth) e.g. Rectangle (5x4) Class Square: . Square extends Rectangle . It has a parameterized constructor with (only) one parameter * It has a method called getSide to expose the side-length of the square No fields are declared in class Square The parameter is used to initialize both fields of Rectangle Override the toString method so that it will return a String of the following form: Square (side) e.g. Square (4)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
