-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathRectangle.java
More file actions
46 lines (34 loc) · 893 Bytes
/
Copy pathRectangle.java
File metadata and controls
46 lines (34 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
public class Rectangle {
private double length;
private double width;
private static int numRectangles;
public Rectangle() {
this(1.0, 1.0);
}//end no-arg ctor
public Rectangle(double length, double width) {
this.length = length;
this.width = width;
numRectangles++;
}//end ctor
public double getLength() {
return length;
}
public double getWidth() {
return width;
}
public void setLength(double length) {
this.length = length;
}
public void setWidth(double width) {
this.width = width;
}
public double area() {
return length * width;
}
public double perimeter() {
return 2 * length + 2 * width;
}
public static int getNumRectangles() {
return numRectangles;
}
}