/ Published in: Java
URL: http://nunnone.com
This is a program to implement a Rectangle. Private fields record the length and width and methods calculate the area and perimeter. It sets a default length and width if one is not given.
Expand |
Embed | Plain Text
private double length; private double width; private double area; private double perimeter; this.length = 1.0; this.width = 1.0; } length = theLength; width = theWidth; } public double getArea() { area = width * length; return area; } public double getPerimeter(){ perimeter = (width * 2) + (length * 2); return perimeter; } }
You need to login to post a comment.
