I making a class and for some reason there is the error "cannot find symbol" for
perimeter = width + length;
return perimeter;
I am not sure why an error should occur here (or whether there is something else wrong with my code. I just started java in school so any tips would be helpful.
/**
* A rectangle has a length and a width. Its perimeter can be calculated.
*/
public class Rectangle
{
private int length;
private int width;
/**
* Constructs a rectangle with a specified length and width
* @param len the length of the rectangle
* @param wid the width of the rectangle
*/
public Rectangle(int len, int wid )
{
length = 0;
width = 0;
}
/**
* Sets the length and width of the rectangle
* @param len the new length
* @param wid the new width
*/
public void setDimensions(int len, int wid)
{
length = len;
width = wid;
}
/**
* Returns the perimeter of the rectangle
* @return the perimeter of the rectangle
*/
public int calculatePerimeter( )
{
perimeter = width + length;
return perimeter;
}