-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShape.java
More file actions
45 lines (37 loc) · 1.08 KB
/
Shape.java
File metadata and controls
45 lines (37 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
public abstract class Shape {
protected Point[] p;
protected int size;
// Mengeluarkan nilai point ke-n
// Pre kondisi: n < size;
public Point getPoint(int n) {
return p[n];
}
// Set nilai point ke n dengan p2
public void setPoint(int n, Point p2){
p[n].setAbsis(p2.getAbsis());
p[n].setOrdinat(p2.getOrdinat());
}
// Set nilai point ke n dengan (x,y)
public void setPoint(int n, int x, int y){
p[n].setAbsis(x);
p[n].setOrdinat(y);
}
// Melakukan pergeseran bidang sebesar point p2
public void translate(Point p2){
for (int n=0; n < p.length; n++) {
p[n].setAbsis(p[n].getAbsis() + p2.getAbsis());
p[n].setOrdinat(p[n].getOrdinat() + p2.getOrdinat());
}
}
// Melakukan pergeseran bidang sebesar (x,y)
public void translate(int x, int y){
for (int n=0; n < p.length; n++) {
p[n].setAbsis(p[n].getAbsis() + x);
p[n].setOrdinat(p[n].getOrdinat() + y);
}
}
// Menghitung keliling bidang
public abstract double keliling();
// melakukan pencetakan bidang.
public abstract void print();
}