Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A Java programmer has been given the task of implementing agraphics package for

ID: 3611163 • Letter: A

Question

A Java programmer has been given the task of implementing agraphics package for displaying and manipulating images oftriangles and images of circles.

   Suggest two classes which might be useful in agraphical package. It is not necessary to show any Java codedefiniing these classes,
   Now suggest a method which is applicable to bothtriangles and circles. Suggest a second method which is applicableto triangles but which is not applicable to circles. It issufficient to give a general idea of the actions of the twomethods. It is not necessary to show any Java code.



Explanation / Answer

two class names would be: Triangle, Circle.   -since you are dealing with triangles and circles. A method applicable to both classes could be: getShape(Stringshape); A method applicable to traingle but not circle would be: getHypotenuse(double side1, double side2); getShape() just returns a string representation of theobject. We could check by implementing a boolean statement tosee if the object was of type triangle or circle. If it is atriangle, we could perform whatever tests the programmer desiredpertaining to triangle ... and likewise for circles. Wewouldn't perform operations that pertain to circles on thetriangles, it might crash the program. the getHypotenuse would take in 2 parameters - the sides of thetriangle. the code itself would utilize the geometric formulato derive the hypotenuse. (square root of side1 squared +side2 squared). the squareroot function is in the math classand should be imported into the triangle class in order to beuseful, otherwise it would cause an error. hopefully this is helpful

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote