Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

program shuld be in java..need urgent Q2. You are given the following classes: Shape (abstract), Rectangle, Ellipse, Triangle, Square. Circle and Sphere. The inheritance diagram

image text in transcribed

image text in transcribed

program shuld be in java..need urgent

Q2. You are given the following classes: Shape (abstract), Rectangle, Ellipse, Triangle, Square. Circle and Sphere. The inheritance diagram is as follows: (20) Shape K pos: int Y_postin +getAreal: double get Perimeter): double getVolumel)double Rectangle length: int -width: int Triangle side int sident -side Hint get Areadouble getPerimeter): double getVolumel): double Ellipse -K_radius: int V_radius int getAreal): double petPerimeter) double getVolumel) double +getArea: double Perimeter): double #getVolumel): double Square Circle getAreal)double petPerimeter: double Volumel): double BetArea double getPerimetert): double getVolumel): double Sphere *petAreal): double getPerimeter): double +getVolumel) i double Complete the main0 method in the TestShapes class to: 1) Declare an ArralyList with initial capacity of 1000 Shape references. 2) Generate randomly 1000 objects of Rectangle, Triangle, Square, Ellipse and Circle objects that will be referred by the Shape references. 3) Calculate and print the total perimeter of the Triangle objects. 4) Calculate and print the total area of the Rectangle objects. 5) Calculate and print the total volume of the Sphere objects. 6) Print the number of objects of each geometric shape available. 7) Sort the objects based on the Euclidean distance (ED): ED = x_coord? + y_coord? Hint: Implement the Comparator interface in a class called EuclideanDistanceComparator to sort the array objects using the Euclidean distance defined above. 8) Print the "smallest" element according to the ED measure. 9) Print the "largest element according to the ED measure. Q3. Write a code to show exception handling of any exception in the above program and put comments there

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_2

Step: 3

blur-text-image_3

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

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

Students also viewed these Databases questions

Question

The paleolithic age human life, short write up ?

Answered: 1 week ago

Question

1. Which position would you take?

Answered: 1 week ago