Question: In this assignment you will create 2 interfaces: Shape and Printable and you will modify the classes Rectangle, Square,IsoscelesRightTriangle, and Circle so that they implement
In this assignment you will create 2 interfaces: Shape and Printable and you will modify the classes Rectangle, Square,IsoscelesRightTriangle, and Circle so that they implement one or both of the interfaces.In addition, you will create a class called InterfaceApp (different from InheritanceApp). This class includes the main method and demonstrates the polymorphic behavior of interfaces.Declare the interfaces according to the UML diagrams: ad interface Shape:
perimeter .. returns the perimeter of the shape
area .. returns the area of the shape
ad interface Printable:
print prints the outline of the shape with stars (*)
within a line the stars are always separated by a single space (blank) The rectangle is printed with the length on the x-axis (more wide than high) In case of the triangle the right angle is on the bottom left ( see output ) The output produced by the print method needs to reflect the actual field values
Modify the four shape classes Rectangle, Square, IsoscelesRightTriangle, and Circle so that all of them implement Shape
all except Circle implement Printable
ad InterfaceApp: This class includes the main method. This assignment does NOT accept user input
Create instances of Rectangle, Square, IsoscelesRightTriangle, and Circle and assigns them to variables of type Rectangle, Square, IsoscelesRightTriangle, and Circle.The rectangle has length 6 and width 3 The square has a side length of 5 The triangle has a leg size of 6 The circle has a radius of 5
All arguments passed to the constructors are hard-coded in the main method.
For each of the 4 instances print the object (toString)For Circle calculate the diameter and circumference and print the results
Print the string Shape Array: and underline it with dashes
Create an array of the interface type Shape
Initialize it with the four shape instances we created above
Loop through all the elements of the array. For each of the array elements do the following:
print the shape (toString)
print the perimeter
print the area
if the shape is printable, print the shapeHint: use instance of to find out whether a shape is printable
print a new line to structure the outputThe output should look like the output provided on the right




Interface Shape perimeter double area double
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
