Question
Implement a class Triangle that represents triangles. The constructor should accept the lengths of a triangles three sides as integers and verify that they are
Implement a class Triangle that represents triangles. The constructor should accept the lengths of a triangles three sides as integers and verify that they are valid by testing whether the sum of the lengths of any two sides exceeds the length of the third side. If the triangle is not valid, print a message to the screen saying that and set all three variables to -99. The class should define three boolean-valued methods isRight, isIsosceles, isEquilateral which test whether the triangle is right, isosceles, or equilateral. Write a toString method that displays the side lengths of the triangles in the following format:
a:3
b:3
c:3
Write an equals method that returns true is the triangle has equal sidelengths.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started