Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2 of 2 Design and write a Java class named Triangle Triangle.java) that extends the GeometricObject class (Note: GeometricObject class MUST be exactly the same
2 of 2 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 sts - side 1) - side 2) - 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 toString 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. Deliverable(s) Submit the following file(s) on the Blackboard: Triangle.java TriangleTest.java
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started