I have to extend the class geometric object to class triangle.
I cannot seem to find the error which causes the compiler to say
"must implement the inherited method GeometricObject.getArea" "must implement the inherited method GeometricObject.getPerimeter"
Here is my code for triangle
public class Triangle extends GeometricObject {
double side1 = 1.0;
double side2 = 1.0;
double side3 = 1.0;
public Triangle()
{
}
public Triangle(double s1, double s2, double s3)
{
double side1 = s1;
double side2 = s2;
double side3 = s3;
}
public void getSide1()
{
System.out.print(side1);
}
public void getSide2()
{
System.out.print(side2);
}
public void getSide3()
{
System.out.print(side3);
}
public double getArea(double s1, double s2, double s3)
{
double s = (s1+s2+s3);
double area = Math.sqrt((s-s1)-(s-s2)-(s-s3));
return area;
}
public double getPerimeter(double s1, double s2, double s3)
{
double peri = (s1+s2+s3);
return peri;
}
public String toString()
{
return ("Triangle Side 1: " + side1 + " Triangle Side 2: " + side2 + " Triangle Side 3: " + side3);
}
}
Here is the code for geometricobject
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;
}
/** Return a string representation of this object */
public String toString() {
return "created on " + dateCreated + "\ncolor: " + color + " and filled: " + filled; }
/** Abstract method getArea and getPerimete */
public abstract double getArea(); //abstract method
public abstract double getPerimeter();
}
Can someone point out what did I miss?