-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRectangle.java
42 lines (33 loc) · 990 Bytes
/
Rectangle.java
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
package com.yurii.salimov.lesson04.task02;
/**
* @author Yuriy Salimov ([email protected])
* @version 1.0
*/
public final class Rectangle extends Figure {
private static final String NAME = "Rectangle";
private final double width;
private final double height;
public Rectangle(final double width, final double height) {
this.width = width;
this.height = height;
}
@Override
public double getArea() {
return this.width * this.height;
}
@Override
public String getName() {
return NAME;
}
public double getWidth() {
return this.width;
}
public double getHeight() {
return this.height;
}
public static Rectangle combine(final Rectangle first, final Rectangle second) {
final double width = first.getWidth() + second.getWidth();
final double heigth = first.getHeight() + second.getHeight();
return new Rectangle(width, heigth);
}
}