Question
1. Make an abstract class called Shape. The private attribute is shapeName of String type. It must include constructors (default and parameter), the services (getters
1. Make an abstract class called Shape. The private attribute is shapeName of String type. It must include constructors (default and parameter), the services (getters and setters). It will also have an abstract method of type int called calcArea().
2.Make a concrete class called Parallelogram. This class will be a class derived from the abstract class called Shape. Private attributes are base and height of type double. It must include constructors (default and parameter), the services (getters and setters) for the attributes. You must override the method Call calcArea() to calculate the area of the parallelogram (A = bh). The setBase method and setHeight method must handle data that is greater than than zero, otherwise you must throw to the exception ArithmeticException.
3. Make a class called ShapeDriver. The main method must instantiate the class Parallelogram, Rectangle, and Circle (assume that the Rectangle and Circle classes they're made). Create an array [3] of type Shape and assign each instance of the objects: parallelogram, rectangle and circle created before. Make a loop so that ask the information of each geometric figure. If you enter any negative data main must catch the ArithmeticException exception. make another loop where it will present the information of each geometric figure: the name of the figure, the sides, and the area of the figure.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started