Question: Design a class named Triangle that extends GeometricObject (as shown below). The class should contain the following three private double data fields: side1, side2, side
Design a class named Triangle that extends GeometricObject (as shown below). The class should contain the following three private double data fields: side1, side2, side 3 with default values 1.0 to denote three sides of the triangle. In addition, the class should have the following constructors and methods: 1. A no-arg constructor that initializes all three sides to 0. 2. A constructor that creates a triangle with the specified side1, side2, and side3. 3. The setter methods for three data fields. 4. The getter methods for three data fields. 5. A method named getPerimeter() that returns the perimeter of this triangle. 6. A method named toString() that returns a string description for the triangle. Write a test program that does the following tasks: 1. Prompts the user to enter three sides of the triangle. The program creates a Triangle object with these sides. Prompt the user to enter a color and a Boolean value to indicate whether the triangle is filled. Use these two input values to set the data fields color and filled. 2. Invoke the Triangle object's getPerimeter() and toString() methods
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
