Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

pls adivse some coding This question will test your ability to use: Inheritance, exception handling and object file processing The following UML diagram shows the

image text in transcribed

image text in transcribedpls adivse some coding

This question will test your ability to use: Inheritance, exception handling and object file processing The following UML diagram shows the relationship of three unknown shapes: Shape_1 double a +Shape_1(double a) + double areal * double perimetero String toStringo R. Shape_2 s double b Shape_2(double a double b) + double area + double perimeter String toStringo Shape_3 - double Shape_3(double a double b, double c) + double area + double perimetero String to String The main objective of this question is to assume that all classes implement the Serializable interface so that you can construct and process serializable objects. The class Shape_1 has only one instance variable (double type). Based on this instance variable, we can imagine a to be the radius of a circle object; it can also be the sides of a square (all the four sides are the same) and it can also be an equilateral triangle (all the three sides are the same). The class Shape_2 is a subclass of Shape_1 has one more instance variable b. Implicitly we have two instance variables (a and b) in this class. We can imagine a and b can be the length and the width of a rectangle or the sides of an isosceles triangle (two sides are equal to a, the third side is b). The class Shape_3 is a subclass of Shape_2 has one more instance variable Implicitly we have three instance variables (a, b, and c). We can imagine a, b and care the three sides of a triangle or a parallelogram (two sides are a, the other two sides are b and cis the height, just like a trapezoid). For each shape object, we can compute its area and its perimeter. A toString method to return the String representation of each shape's object. For example, you can just return a, or a, b or a, b, c, respectively, for each of the three shapes. When implementing these three classes, you don't have to cater for all possible shapes, you choose one specific shape for each class. For example, you can assume that objects constructed from class Shape_1 are just like circle objects; objects constructed from class Shape_2 are just like rectangle objects and objects constructed from class Shape_3 are just like triangle objects. The most important of the question should be the main class. Here is the UML diagram: Supp2 -static ObiectinputStream input -static Obiecto pulstream output -static double geValue -static void createObiectFile(String fileName) static void processobiectFile(String fileName) + static void main(strinal args) Two important methods in the main class: create a file consists of some serializable objects and process the serializable file. Upon execution, you will see the following interactions and displays: In creation, you need to construct at least one object of each class and store them in an object file. All information are randomly generated: Begin creation of infile.ser ==> adding an object of Shape_1 to infile.ser => adding an object of Shape_2 to infile.ser ==> adding an object of Shape_3 to infile.ser Objects ready to write to infile.ser Object file infile.ser successfully created In processing, you should let Java process it polymorphically. Here is the display: Begin processing of infile.ser polymorphically Object is Shape_1 (1.817) Its area is 10.369 Its perimeter is 11.415 Object is Shape_2 (77.875, 96.413) Its area is 7431.084 Its perimeter is 346.977 Object is Shape_3 (69.749, 26.924, 74.745) Its area is 938.963 Its perimeter is 193.346 All objects processed *** Note that the following statements are printed in the finally block All tasks in Question 2 completed infile. ser closed for processing

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

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions