Question: Java programming code Write a program that creates two classes Circle and Trapezoid. For each class, provide method getters and setters, method area() that will
Java programming code
Write a program that creates two classes Circle and Trapezoid. For each class, provide method getters and setters, method area() that will calculate the area of the shape, and method toString() that will display the class name. Use private data fields. The constructor of each class should set a default value for each shape. For class Circle, set the default radius to 4 inches. For class Trapezoid set the default values to 15 inches for Base a, 5 inches for Base b, and 25 inches for the height (see diagram below as an example) Using the Java ArrayList class and the loop concept, create five objects of the given shapes above. Which object to create and load into an array depends on your random number generator between 1 to 2. If the random number is 1, then using your default constructor create and load a Circle object into your ArrayList. If the random number is 2, then using your default constructor create and load a Trapezoid object into your ArrayList. In your program, you are required to use Java ArrayList class to store your objects. Use the array declaration given below in your program: //Generic Arraylist with default capacity ArrayList
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
