-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRectangle.java
More file actions
51 lines (40 loc) · 1.08 KB
/
Rectangle.java
File metadata and controls
51 lines (40 loc) · 1.08 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
package com.yurii.salimov.lesson03.task05;
/**
* @author Yuriy Salimov (yuriy.alex.salimov@gmail.com)
* @version 1.0
*/
public class Rectangle extends Figure {
private static final String NAME = "Rectangle";
private double width;
private double height;
public Rectangle(double width, 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 void setWidth(double width) {
this.width = width;
}
public double getHeight() {
return this.height;
}
public void setHeight(double height) {
this.height = height;
}
public static Rectangle combine(final Rectangle rectangle1, final Rectangle rectangle2) {
return new Rectangle(
rectangle1.getHeight() + rectangle2.getHeight(),
rectangle1.getWidth() + rectangle2.getWidth()
);
}
}