superclasses
publicvoid calculateArea(double area)
{
area = width * height / 2;
}
I have the above code in a seperate class to my super class, i have already done my constructor above this and called the super class in that fine. e.g.super(width, height);
whatever i try for this void method it will not let me access the width and height as they are in the super class, a was wondering the way to solve this so it works! pls.
you could make those variables protected rather than private, although arguably that violates encapsulation. you could also provide getter methods for your superclass to return those values, and call them from within the method you posted. eg
public void calculateArea(double area) {
area = getWidth() * getHeight() / 2;
}
//Returns a string representing the values of all the attributes of the triangle
public String toString()
{
return height + width +"Triangle Style is: "+ triangleStyle;
}
i know for this return string method u have to use something along the lines of return super.toString()
the triangleStyle is fine as it is only in my triangle class its the other 2 again that wont access.
1 i have compiled this correctly my whole program should work correctly!
sorry 4 been a pain