Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

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 Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions