Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

program should be in java...need both questions within 40 mint Shape -x_pos: int -Y_pos: int +getAreal): double +getPerimeter(): double +getVolume(): double Triangle -sideA: int -sideB

image text in transcribedimage text in transcribed

image text in transcribed

program should be in java...need both questions within 40 mint

Shape -x_pos: int -Y_pos: int +getAreal): double +getPerimeter(): double +getVolume(): double Triangle -sideA: int -sideB : int -sideC: int +getArea(): double +getPerimeter(): double +getVolume(): double Rectangle -length : int -width: int +getAreal): double +getPerimeter(): double +getVolume(): double Ellipse -x_radius: int -v_radius: int +getArea(): double +getPerimeter(): double +getVolume(): double Square Circle +getAreal): double +getPerimeter(): double +getVolume(): double +getArea(): double +getPerimeter(): double +getVolume(): double Sphere +getAreal): double +getPerimeter(): double +getVolume(): double 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

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

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions

Question

Explain the various methods of job evaluation

Answered: 1 week ago

Question

Differentiate Personnel Management and Human Resource Management

Answered: 1 week ago

Question

Describe the functions of Human resource management

Answered: 1 week ago