generated from JavaLabs2025/reflection-template
-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathRectangle.java
More file actions
34 lines (28 loc) · 833 Bytes
/
Rectangle.java
File metadata and controls
34 lines (28 loc) · 833 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
package org.example.classes;
import org.example.generator.Generatable;
@Generatable
public class Rectangle implements Shape {
private double length;
private double width;
public Rectangle(double length, double width) {
this.length = length;
this.width = width;
}
@Override
public double getArea() {
return length * width;
}
@Override
public double getPerimeter() {
return 2 * (length + width);
}
@Override
public String toString() {
return "Rectangle{" +
"length=" + String.format("%.2f", length) +
", width=" + String.format("%.2f", width) +
", area=" + String.format("%.2f", getArea()) +
", perimeter=" + String.format("%.2f", getPerimeter()) +
'}';
}
}