Rectangle - { return length; } public double getWidth() {...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
i public class Rectangle { private double length; private double width; public Rectangle() { length = 0; width = 0; } public Rectangle(double l, double w) { setDimension(l, w); } public void setDimension(double l, double w) { if (l >= 0) length = l; else length = 0; if (w >= 0) width = w; else width = 0; } public double getLength()
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { return length; } public double getWidth() { return width; } public double area() { return length * width; } public double perimeter() { return 2 * (length + width); } public void print() { System.out.print("Length = " + length + "; Width = " + width); } }...
View Full Document

Ask a homework question - tutors are online