Question: Shape Class Create a superclass called Shape with an instance method Displaylnfo that will return a string containing the name, area and perimeter of the

Shape Class
Create a superclass called Shape with an instance method Displaylnfo that will return a string
containing the name, area and perimeter of the shape.
public String DisplayInfo(){
The superclass has the following instance variables: ShapeName (String), Area (double) and
Perimeter(double). Also create an instance methods setArea and setPerimeter.
Create a subclass of Shape called Circle witi an instance variable radius (private double) and
create a constructor for this subclass. Also create the following instance methods: Area (method
that will return the area of a circle), Perimeter (method that will return the perimeter of a
circle), and the set and get for the instance variable.
Create another subclass of Shape called Rectangle with instance variables (private length and
private width) and create a constructor for this subclass. Also create the following instance
methods: Area (method that will return the area of a rectangle), Perimeter (method that will
return the perimeter of a rectangle) the set and get for the instance variables.
Create a class ShapeTest that will demonstrate polymorphism. Create at least two objects to test
the two subclasses. Ask for the keyboard input from the user for the needed values to compute
the Area and Perimeter for both Circle and Rectangle.
Shape Class Create a superclass called Shape with

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!