-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRectangle.java
More file actions
35 lines (29 loc) · 953 Bytes
/
Rectangle.java
File metadata and controls
35 lines (29 loc) · 953 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
public class Rectangle extends Shape {
public final float height;
public final float width;
private Rectangle(Color color, String name, float height, float width) {
super(color, name);
this.height = height;
this.width = width;
}
public static class Builder extends Shape.Builder<Rectangle.Builder> {
private float height;
private float width;
public Builder height(float height) {
this.height = height;
return this;
}
public Builder width(float width) {
this.width = width;
return this;
}
@Override
public Rectangle build() {
return new Rectangle(this.color, this.name, this.height, this.width);
}
}
@Override
public String toString() {
return "Rectangle: name = " + name + ", color = " + color + ", height = " + height + ", width = " + width;
}
}