Question: Design and write a Java class named Triangle Triangle.java) that extends the GeometricObject class (Note: GeometricObject class MUST be exactly the same as the sample

 Design and write a Java class named Triangle Triangle.java) that extends

Design and write a Java class named Triangle Triangle.java) that extends the GeometricObject class (Note: GeometricObject class MUST be exactly the same as the sample codes and no need to submit it I have this class.). The Triangle class contains: Three double data fields named sidel, side2, and side3 with default values 3.0, 4.0, 5.0 to denote three sides of a triangle. A no-arg constructor that creates a default triangle. A constructor that creates a triangle with the specified sidel, side2, and side3. The accessor (getter) methods for all three data fields. The mutator (setter) methods for all three data fields. A method named getArea() that returns the area of this triangle. The formula for computing the area of a triangle is $ = (sidel + side2 + side3)/2: area = Vsts - sidel)( - side 2)Cs - side 3) A method named getPerimeter() that returns the perimeter of this triangle. Overriding toString() method to return a string description for the triangle. This overridden method must call the toString0 method from its superclass (use keyword super) and adds the sides information to the returned string. (Please see the sample codes for more hints) Write a testing Java application (Triangle Test.java) that tests ALL the constructors and methods mentioned above with at least the following features: Prompting user to enter three sides of a triangle, a color, and a boolean value (for filled data field). Then, creating a Triangle object with these values. Creating an object with actual type Triangle and declared type GeometricObject. Then, calling toString() method on it. Calling toString() method on an object with actual type GeometricObject. Writing a statement to downcast a GeometricObject instance. Writing a statement to upcast a Triangle instance

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!