Question: Program # 1 ( 5 0 points ) : Design and implement class Triangle that inherits from class GeometricObject ( provided with this assignment and

Program #1(50 points): Design and implement class Triangle that inherits from class GeometricObject (provided with this assignment and required for submission). Class Triangle has the following characteristics: 1. Defines three private variables of type double: side1, side2, and side3. Each is initialized with the value of 1.0.2. Defines a default (non-argument) constructor method to create default triangle objects (with default sides).3. Defines a second constructor to allow the user to create triangle objects with user-specific input values for all sides. The constructor rejects negative values (invalid) for a side. 4. Defines three access (get) methods, one for each variable, named as getSide1(), getSide2(), and getSide3(). Get methods reject negative values (invalid) for a side. 5. Defines three access (set) methods, one for each variable, named as setSide1(), setSide2(), and setSide3(). Set methods reject negative values (invalid) for a side. 6. Defines method getArea() that computes and returns the area of a triangle object. Here is the math (Herons formula) for the area computation: double s =(side1+ side2+ side3)/2.0 double Area = Sqrt(s(s-side1)(s-side2)(s-side3))7. Defines method getPerimeter() that computes and returns the perimeter of a triangle object. Here is the math for perimeter computation: Perimeter =(side1+ side2+ side3)8. Defines method toString() that returns a meaningful description of a triangle object including its name, sides, area, and perimeter in the following format (the values below are just an example for illustration purposes). Make sure your code displays the outputs following the test data format. Please add blank line before and after this output. ------- blank line Triangle: myTriangle Side 1: 4.0 Side 2: 5.0 Side 3: 6.0 Area: 9.921567416492215 Perimeter: 15.0 Color: White Is Filled: true

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 Programming Questions!