我做的一个类和某些原因“无法找到符号”为错误无法找到符号
perimeter = width + length;
return perimeter;
我不知道为什么这里会出现一个错误的错误(或者是否有别的东西错了我的代码,我只是在学校里开始了Java的,因此任何提示将是有益的。
/**
* 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;
}
'parameter'从未定义? – Li357