Right Triangle Shape
Create and complete the implementation of the RightTriangle
class.
Your class should be public, not final and not abstract, inherit from the Shape
class,
and provide the following methods:
- Constructor that takes a
double
parameter. Creates a newRightTriangle
with the passed side length. You can assume that the passed size is greater than zero. You should call theShape
constructor and pass it theString
"righttriangle" to identify the type of this shape. - Public instance method
area
that takes no arguments and returns adouble
. Return the area of this shape:side * side * 0.5
. - Override
public boolean equals(Object other)
. Returntrue
ifother
is aRightTriangle
with the same side length, andfalse
otherwise. Note thatother
may benull
or not aRightTriangle
.
Finally, note that your class should not expose any of its internal state publicly.