Question: Define a Triangle class with three private double instance variables, each of which represents the length of one side of the triangle, and a single

 Define a Triangle class with three private double instance variables, each

Define a Triangle class with three private double instance variables, each of which represents the length of one side of the triangle, and a single three-argument constructor. For any triangle, the sum of any two sides must be greater than the remaining side. Your Triangle class must adhere to this rule. 2. Define an IllegalTriangleException class (an empty subclass of Exception), and define Triangle's constructor to raise an IllegalTriangleException if the user attempts to create a Triangle whose sides violate the rule above. Your Triangle constructor header should resemble the following: /**Construct a triangle with the specified sides */ public Triangle (double sidel, double side2, double side3) throws IllegalTriangleException // Implement your constructor Finally, define a main() method (inside Triangle or in a separate diver class) that prompts the user to enter a length for each side, and then creates a new Triangle with those values. If the user enters an invalid set of values (meaning that the Stony Brook University CSE 114: Computer Science I Fall 2017 Triangle constructor generates an exception), your program should use exception- haning to prit an appropriate messag instead of simply crashing

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!