Write a class named Triangle in Java that extends class Geom
Write a class named Triangle in Java that extends class GeometricObject. The Triangle class contains:
 • Three double properties named side1, side2, and side3 with default values 1.0 to denote three sides of the triangle.
 • A no-arg constructor that creates a default triangle.
 • A constructor that creates a triangle with the specified side1, side2, and side3.
 • The get methods for all three properties.
 • A method named getArea() that returns the area of this triangle.
 o Use following formula to compute the area of a triangle.
 s = (side1 + side2 + side3) / 2
Use Java- use comments to explain the code and specify the comments this assignment wants.Show me where I need to put my full name, course number and name, the number of assignment, and the date of last successful debugging in the comments for my source file of the test class.
Solution
public abstract class GeometricObject {
    private String color = \"white\";
    private boolean filled;
    private java.util.Date dateCreated;
   /** Construct a default geometric object */
    protected GeometricObject() {
        dateCreated = new java.util.Date();
    }
   /** Construct a geometric object with color and filled value */
    protected GeometricObject(String color, boolean filled) {
        dateCreated = new java.util.Date();
        this.color = color;
        this.filled = filled;
    }
   /** Return color */
    public String getColor() {
        return color;
    }
   /** Set a new color */
    public void setColor(String color) {
        this.color = color;
    }
   /**
    * Return filled. Since filled is boolean, the get method is named isFilled
    */
    public boolean isFilled() {
        return filled;
    }
   /** Set a new filled */
    public void setFilled(boolean filled) {
        this.filled = filled;
    }
   /** Get dateCreated */
    public java.util.Date getDateCreated() {
        return dateCreated;
    }
   @Override
    public String toString() {
        return \"created on \" + dateCreated + \"\ color: \" + color
                + \" and filled: \" + filled;
    }
   /** Abstract method getArea */
    public abstract double getArea();
   /** Abstract method getPerimeter */
    public abstract double getPerimeter();
 }
public class Triangle extends GeometricObject {
   private double side1;
    private double side2;
    private double side3;
   /**
    * @param side1
    * @param side2
    * @param side3
    */
    public Triangle(double side1, double side2, double side3) {
        this.side1 = side1;
        this.side2 = side2;
        this.side3 = side3;
}
   /**
    *
    */
    public Triangle() {
        this.side1 = 1.0;
        this.side2 = 1.0;
        this.side3 = 1.0;
    }
   @Override
    public double getArea() {
       double s = (side1 + side2 + side3) / 2.0;
        return Math.sqrt(s * (s - side1) * (s - side2) * (s - side3));
    }
   @Override
    public double getPerimeter() {
        return side1 + side2 + side3;
    }
   /*
    * (non-Javadoc)
    *
    * @see GeometricObject#toString()
    */
    @Override
    public String toString() {
        return \"Triangle :\" + \"side1=\" + side1 + \", side2=\" + side2
                + \", side3=\" + side3;
    }
   /**
    * @return the side1
    */
    public double getSide1() {
        return side1;
    }
   /**
    * @param side1
    * the side1 to set
    */
    public void setSide1(double side1) {
        this.side1 = side1;
    }
   /**
    * @return the side2
    */
    public double getSide2() {
        return side2;
    }
   /**
    * @param side2
    * the side2 to set
    */
    public void setSide2(double side2) {
        this.side2 = side2;
    }
   /**
    * @return the side3
    */
    public double getSide3() {
        return side3;
    }
   /**
    * @param side3
    * the side3 to set
    */
    public void setSide3(double side3) {
        this.side3 = side3;
    }
}
public class TestTriangle {
    /**
    * @param args
    */
    public static void main(String[] args) {
       
        try {
            Triangle triangle=new Triangle(2, 3, 4);
            System.out.println(triangle);
            System.out.println(\"AREA :\"+triangle.getArea());
            System.out.println(\"Perimeter :\"+triangle.getPerimeter());
        } catch (Exception e) {
            // TODO: handle exception
        }
   }
 }
OUTPUT:
Triangle :side1=2.0, side2=3.0, side3=4.0
 AREA :2.9047375096555625
 AREA :9.0




