Question: 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

 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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!