Create an object oriented program that implements inheritance by creating a parent (superclass) called Shape, and two child classes (1) Circle and (2) Square. All the classes will provide "set" and "get" methods to access the class attributes, and all attribute values will be ranged checked. Each Class shall implement a toString method.
The parent Shape class will have two protected integer attributes "x" and "y" which represent the starting point in x and y coordinates for the child classes. The minimum value for both x and y is 0, and the maximum value for both x and y is 1000. The Shape class default constructor shall initialize the starting point to (500, 500), the Shape class shall have a parameterized constructor that accepts the starting point for the figure and the parameterized constructor shall ensure all starting points passed in are within the bounds of (0, 0) to (1000, 1000). The Shape class shall have Area method that will return the value of 0 (since a general shape has no area).
The Circle class shall inherit from the Shape class and add a radius attribute. The minimum value for radius is 1 and the maximum value is 500. The (x, y) starting point designates the center of the circle. The Circle class shall include a default constructor and parameterized constructor that includes the starting point and the radius. The Circle class shall override the parent Shape Area method to include the calculation of the area of a circle. Also, the Circle class shall implement a Circumference method that calculates the circumference of the circle.
The Square class shall inherit from the Shape class and add a side length attribute; the maximum value of length is 1000. The (x, y) starting point designates the upper left corner of the square. The Square class shall include a default constructor and parameterized constructor that includes the starting point and the side length. The Square class shall override the parent Shape Area method to include the calculation of the area of the square. Also, the Square class shall implement a Perimeter method that calculates the perimeter of a square.
Construct a main program that prompts the user for a starting point and then create a Shape object and display the shape's attributes and area. Prompt the user for the radius of a circle, create a Circle object, and display the area and circumference. Prompt the user for the length of a square, create a Square object, and display the area and perimeter.
Grading Rubric
InheritanceTest
Points
Description
Standard header included
1
Must contain program's name, student name, and description of the program
Program compiles
1
Program does not have any error
Program executes
1
Program runs without any error
Shape class created
3
Class contains constructors, accessor, mutator, area, and toString methods, and all values are ranged checked.
Circle class created
3
Class contains constructors, accessor, mutator, toString, area circumference methods and radius values are ranged checked.
Square class created
3
Class contains constructors, accessor, mutator, toString, area perimeter methods and length values are ranged checked.
InheritanceTest class created
4
Test class prompts for and display for point and shape information, prompts for circle radius and displays circle area and circumference, and prompts for square side and displays square area and perimeter.
Correct output is displayed
4
Tes