Write a superclass GeometricObject (private color and filled, a constructor, the two accessors and toString() giving color red, filled), a subclass Triangle, and a public class TriangleApp.
Triangle adds three sides and:
- a no-argument constructor (a white, unfilled triangle with sides of 1) and a full constructor that passes color and filled to the superclass with
super(...); isValid()— the sum of any two sides exceeds the third;getPerimeter();getArea()(Heron's formula: with s = perimeter / 2, the area is √(s(s − a)(s − b)(s − c)));toString()that extends the inherited one:Triangle: side1 = 3.0 side2 = 4.0 side3 = 5.0, color red, filled.
main reads three sides, a color and true or false. For the input
3 4 5 red true
the program prints
Triangle: side1 = 3.0 side2 = 4.0 side3 = 5.0, color red, filled
Perimeter: 12.00
Area: 6.00
Inherited: color red, filled true
Default: Triangle: side1 = 1.0 side2 = 1.0 side3 = 1.0, color white, not filled