Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please screenshot source code as it is easier for me to follow indentations also this is being coded in java Object-oriented programming (OOP) is a

please screenshot source code as it is easier for me to follow indentations also this is being coded in java
image text in transcribed
Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which may contain data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods. A feature of objects is that an object's procedures can access and often modify the data fields of the object with which they are associated (objects have a notion of "this" or "self"). There is significant diversity of OOP languages, bat the most popular ones are class-based, meaning that objects are instances of classes, which typically also determine their type. Question \#1 Write a program that creates two classes - Circle and Trapezoid. For each class, provide method getters and setters, method areal that will calculate the area of the shape, and method toSiringo 0 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 Traperoid 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) Trapezoid Solve for arba - A=2a+bh a thin b Aane h Heigh Using the Java ArrayL ist 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 detault capacity ArrayList arrayOfShapes = new ArrayListo 0 ; 2 Using loop reiterates through your array of objects and call functions toString0 and area0) to print the class name and its area. Use Math.randown() to generate random numbers between 1 to 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions