- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangle.java
More file actions
Latest commit
52 lines (42 loc) · 1.17 KB
/
Copy pathRectangle.java
File metadata and controls
52 lines (42 loc) · 1.17 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
publicclassRectangle {
privateintsideA;
privateintsideB;
privatePointtopleft;
publicRectangle(intsideA, intsideB, Pointtopleft) {
this.sideA = sideA; //width
this.sideB = sideB; //height
this.topleft = topleft;
}
publicintgetSideA() {
returnsideA;
}
publicvoidsetSideA(intsideA) {
this.sideA = sideA;
}
publicintgetSideB() {
returnsideB;
}
publicvoidsetSideB(intsideB) {
this.sideB = sideB;
}
publicPointgetTopleft() {
returntopleft;
}
publicvoidsetTopleft(Pointtopleft) {
this.topleft = topleft;
}
publicintarea() {
returnsideA * sideB;
}
publicintperimeter() {
return2 * (sideA + sideB);
}
publicPoint[] corners() {
Point[] corners = newPoint[4];
corners[0] = topleft;
corners[1] = newPoint(topleft.getxCoord() + sideA, topleft.getyCoord());
corners[2] = newPoint(topleft.getxCoord() + sideA, topleft.getyCoord() - sideB);
corners[3] = newPoint(topleft.getxCoord(), topleft.getyCoord() - sideB);
returncorners;
}
}