Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

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

Database Design Query Formulation And Administration Using Oracle And PostgreSQL

Authors: Michael Mannino

8th Edition

1948426951, 978-1948426954

More Books

Students also viewed these Databases questions

Question

1. Who should participate and how will participants be recruited?

Answered: 1 week ago