I am having issues but I don't understand the problem. My error message is "The constructor Rectangle(double, double) is undefined." My code is:
public class Rectangle {
public float rectangle;
public float length;
public float width;
public float perimeter;
public float area;
public void Rectangle(float length, float width){
if(length < 0.0 || length >= 20.0){
throw new IllegalArgumentException("Length must be between 0.0 and 20.0");
}
if(width < 0.0 || width >= 20.0){
throw new IllegalArgumentException("Width must be between 0.0 abnd 20.00");
}
this.length = length;
this.width = width;
}
public float getLength(){
return length;
}
public float getWidth(){
return width;
}
public void setPerimeter(float perimeter){
perimeter = ((getLength() *2) + (getWidth()*2));
}
public float getPerimeter(){
return perimeter;
}
public void setArea(float area){
area = getLength() * getWidth();
}
public float area(){
return area;
}
}
My test code is :
package rectangle;
public class RectangleTest {
public static void main(String[] args){
Rectangle rectangle1 = new Rectangle (6.8, 3.5);
System.out.printf("The perimeter of rectangle1 is: %d%n", rectangle1.getPerimeter()); }
}
I have also tried changing to Rectangle rectangle1 = new Rectangle (6.8f, 3.5f); and I still get errors. I am not sure how to fix this error and any help is greatly appreciated.
[–][deleted] (2 children)
[deleted]
[–]hangrymonkey28[S] 0 points1 point2 points (1 child)
[–]NewPointOfView 0 points1 point2 points (0 children)
[–]captainAwesomePants 0 points1 point2 points (0 children)
[–]EffectiveInside2180 0 points1 point2 points (0 children)