printing of area
i have this driver file
Rectangle rect =new Rectangle(12,7);
System.out.println(rect.toString());
here is the super class
public class TwoDShape
{
privatedouble width;
privatedouble height;
/*
The defaultConstructor for objects of class TwoDShape
*/
public TwoDShape()
{
}
/*
* A Constructor for objects of class TwoDShape
* param width the width of the shape
* param height the height of the shape
*/
public TwoDShape(double width,double height)
{
this.width = width;
this.height = height;
}
/*
* getter method for width
* return the width
*/
publicdouble getWidth()
{
return width;
}
/*
* getter method for height
* return the height
*/
publicdouble getHeight()
{
return height;
}
/*
* setter method for width
* param width the new value for width
*/
publicvoid setWidth(double width)
{
this.width = width;
}
/*
* setter method for height
* param height the new value of height
*/
publicvoid setHeight()
{
this.height = height;
}
/*
* produces a string representation of the class
* return the String represntation of the class attributes
*/
public String toString ()
{
String temp =new String("\nWidth is: " + width +"\nHeight is: " + height);
return temp;
}
}
my rectangle class is as below
publicclass Rectangleextends TwoDShape
{
String styleAttribute ="Rectangle";
double area;
public Rectangle(double width,double height)//constructor with two parameters
{
super(width, height);
}
//Calculates the area of the rectangle
publicdouble calculateArea()
{
area = getWidth() * getHeight();
return area;
}
public String getStyleAttribute()
{
return styleAttribute;
}
//Returns a string representing the values of all the attributes of the rectangle
public String toString()
{
// call toString() method of superclass
String temp =new String ("Style Attribute is: " + styleAttribute +"\nRectangle area is: "+ area + super.toString());
return temp;
}
}
why does my area print out at 0 and how can i solve this problem, thanks!!!!

