Designing a class extending other class-calculating area


Question 1) Design the class named Triangle which extends GeometricObject. The class contains:

a) Three double data fields named side1, side2, and side3 with default values 1.0 to denote three sides of triangle.

b) A no-arg constructor which creates the default triangle.

c) A constructor which creates the triangle with specified side1, side2, and side3.

d) The accessor methods for all three data fields.

e) A method named getArea() which returns area of this triangle.

f) A method named getPerimeter()which returns a perimeter of this triangle.

g) A method named toString()which returns the string description for the triangle.

The toString() method is implemented as follows:

return"Triangle: side1 = " + side1 + " side2 = " + side2 +" side3 = " + side3;

Draw UML diagram which involves the classes Triangle and GeometricObject. Implement the class. Write the test program which creates a Triangle object with sides 1, 1.5, 1, color yellow and filled true, and displays area, perimeter, color, and whether filled or not. Write all three classes in three separated files: FirstInitialLastNameProject4.java, GeometricObject.java, and Triangle.java.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Designing a class extending other class-calculating area
Reference No:- TGS04688

Expected delivery within 24 Hours