-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangle.java
More file actions
39 lines (30 loc) · 811 Bytes
/
Rectangle.java
File metadata and controls
39 lines (30 loc) · 811 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
package unit_07.Examples.Example_10;
public class Rectangle extends GeometricShape {
protected double length, width;
public Rectangle() {
this(0, 0);
}
public Rectangle(double length, double width) {
this.length = length;
this.width = width;
}
public void setLength(double length) {
this.length = length;
}
public void setWidth(double width) {
this.width = width;
}
public double getLength() {
return length;
}
public double getWidth() {
return width;
}
public void calculate() {
area = length * width;
perimeter = 2 * (length + width);
}
public String toString() {
return String.format("Rectangle:\nLength = %6.2f Width = %6.2f\n", length, width);
}
}