Home / Expert Answers / Computer Science / nbsp-modified-the-triangle-class-you-created-for-lab-2-in-a-triangle-the-sum-of-any-two-si-pa517

(Solved):   Modified the Triangle class you created for lab #2. In a triangle, the sum of any two si ...




Modified the Triangle class you created for lab #2. In a triangle, the sum of any two sides is greater than the other side.
1

 

Modified the Triangle class you created for lab #2. In a triangle, the sum of any two sides is greater than the other side. 1. Define the IllegalTriangleException class that extends the Exception class. This class contains only two constructors: a no-arg constructor and a constructor which takes a string parameter. 2. Modify the second constructor of the Triangle class (The constructor creates a triangle with the specified side1, side2, and side3). In this constructor, if the three sides violate the rule specified above, throw an IllegalTriangleException exception. Write a test program that does the following tasks: 1. Create a text file called sides. txt which contains three randomly generated integers between 1 and 10. 2. Input the three integers from the sides. txt file. 3. Write a try block. In the block, create a new Triangle object using the three integers. 4. Write a catch block to handle the IllegalTriangleException. In the block, print the message: "HlegalTriangle Exception: The triangle cannot be created."


We have an Answer from Expert

View Expert Answer

Expert Answer


Since, no details about the language were provided in the question, I am doing the code in java. In case of any issues, feel free to comment. First, l
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe