-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangle.java
More file actions
65 lines (51 loc) · 1.32 KB
/
Copy pathRectangle.java
File metadata and controls
65 lines (51 loc) · 1.32 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
55
56
57
58
59
60
61
62
63
64
65
package Homework1;
import java.lang.*;
import java.math.*;
public class Rectangle extends Shape {
protected double width;
protected double length;
public Rectangle(String color, boolean filled, double width, double length) {
super(color, filled);
this.width = width;
this.length = length;
}
public Rectangle(double width, double length ) {
this.width = 10.0;
this.length = 0.0;
this.filled = false;
this.color = "purple";
}
public Rectangle() {
this.width = width;
this.length = length;
this.filled = false;
this.color = "purple";
}
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;
}
public double getArea() {
return
width*length;
}
public double getPerimeter() {
return
2*(width+length);
}
@Override
public String toString() {
return "Rectangle{" +
"width=" + width +
", length=" + length +
'}';
}
}