• Write an abstract class named Shape. Shape has one instance variable named shapeName of type String. Write the getters and setters, both constructors, and a toString() method. Also write an abstract method named getArea() that returns a specific shape’s area as a double.
  • Define a concrete class named Square that inherits from Shape. It should contain an instance variable named side which represents the length of a side of the square. Provide both constructors (each needs to set the shapeName to square), a toString() method and appropriate getters and setters. Make certain that the value of side is not less than zero. Write the getArea() method.
  • Define a concrete class named Rectangle that inherits from Shape. It should contain two instance variables named length and width which represents the length and width of a side of the rectangle. Provide both constructors (each needs to set the shapeName to rectangle), a toString() method and appropriate getters and setters. Make certain that the value of neither side is less than zero.Write the getArea() method.
  • Define a concrete class named Circle that inherits from Shape. It should contain one instance variable named radius which represents the radius of the circle. Provide both constructors (each needs to set the shapeName to circle), a toString() method and appropriate getters and setters. Make certain that the value of the radius is not less than zero. Write the getArea() method.
  • Write a driver program named ShapeDriver that creates an array of eight shapes. Call the full constructor to create the following items and then add them to the array.
Circle - radius = 5
Square - side = 10
Circle - radius = 8.3
Rectangle - length = 5; width = 2
Square - side = 6.9
Circle - radius = 3.7
Rectangle - length = 7; width = 4
Circle - radius = 9
  • Write a method named calcAllAreas() that takes in the array as a parameter and prints out the area of each shape as well as the total area of all shapes.
  • Write a method named printAll() that takes in the array and prints out all objects by calling their toString() methods.
  • Write a method named countShapes() that prints out how many Circles, Rectangles, and Squares there are.
  • Write a small menu that can be used to choose between the three methods above or to quit.
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.