-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangle.java
More file actions
54 lines (38 loc) · 1.02 KB
/
Rectangle.java
File metadata and controls
54 lines (38 loc) · 1.02 KB
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
47
48
49
50
51
52
53
54
public class Rectangle extends Shape {
protected double width;
protected double length;
public Rectangle() {
}
public Rectangle(double width, double length) {
this.width = width;
this.length = length;
}
public Rectangle(double width, double length, String color, boolean filled) {
super(color, filled);
this.width = width;
this.length = length;
}
public double getArea() {
return width * length;
}
public double getPerimeter() {
return 2 * (width + length);
}
@Override
public String toString() {
return "Rectangle{" + "width=" + width + ", length=" + length
+ ", color=" + color + ", filled=" + filled + '}';
}
public double getWidth() {
return width;
}
public void setWidth(double width) {
this.width = width;
}
public double getLength() {
return length;
}
public void setLength(double length) {
this.length = length;
}
}