So getArea calls getHeight which calls getArea and creates a never ending loop. I'm being graded on writing as little code as possible and reusing as many functions as possible.
Is there anyway I could get this working with the function calls rather then just substituting the forumula for getArea into getHeight where getArea is called?
//returns the area of a trapezoid
public double getArea(){
double height = getHeight();
double area = (.5 * ((getPoint(3).getX() - getPoint(4).getX()) + (getPoint(2).getX() - getPoint(1).getX()))) * height;
return area;
}
//returns the height of a trapezoid
public double getHeight(){
double area = getArea();
double height = (2 * area) / (((getPoint(3).getX() - getPoint(4).getX()) + (getPoint(2).getX() - getPoint(1).getX())));
return height;
}