Java Program 1
GeometricTriangle class
Design a class named GeometricTriangle that inherits from GeometricObject (what we did in class).
The class contains:
· Three double data fields named side1, side2 and side3 with default values 1.0 to denote three sides of a triangle.
· A default constructor that creates a default triangle
· A constructor that creates a triangle with specified three sides.
· The accessor and mutator methods.
· A method named getArea() that returns the area of the triangle.
o Before the area is calculated check for valid input. Sum of any two sides should be greater than the third one. If not throw an IllegalArgumentException.
· A method named getPerimeter() that returns the perimeter of the triangle.
· A method named toString() that returns the string description for the triangle like for the circle and rectangle.
For a triangle with sides a,b and c area is calculated using semiperimeter s as shown below:
You can write a main to test the class the functions and the exception.
7 years ago
10
Purchase the answer to view it

- assignment.java
- BUS 235 The Marketing Activities of Walmart
- Pricing and Distribution Strategies
- ECO 204 Week 2 Discussion 2 ( Externalities ) - Tutorial Contains Two Answers For this Discussion - A Graded
- First National Bank Investment Decision
- MIS 535 Managerial Application of IT Week 5 Complete Devry
- MIS
- A-plus Writer - Case Study: Michael Dell—The Man Behind Dell Presentation (Change Management)
- Focus group report
- The words in this activity end in the sounds you hear at the end of whistle and whisper, but the...
- Project management