Newer
Older
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
public abstract class Koerper {
// . z
// .
// .
// .
// .
// .
// . +>>>>>>>>>>>>+
// +./|.........../| y
// . +<<<<<<<<<<<<+ |
// . c| +>>>>>>>>>>|>+
// . |/ a |/
// . +<<<<<<<<<<<<+
// . x b
private double x;
private double y;
private double z;
private String farbe = "black";
public Koerper( double x, double y, double z ) {
this.x = x;
this.y = y;
this.z = z;
}
// abstract methods
public abstract double berechneOberflaeche();
public abstract double berechneVolumen();
public abstract String getParameter();
public abstract void skaliere(double alpha);
public abstract boolean istImKoerper( double x, double y, double z );
// final methods
public final String istEin() {
if( this instanceof Quader ) {
return "Quader";
} else {
return "Kugel";
}
}
public final void verschiebeHorizontal(double schritte) {
this.y = this.y + schritte;
}
public final void verschiebeVertikal(double schritte) {
this.z = this.z + schritte;
}
public final void verschiebeTiefe(double schritte) {
this.x = this.x + schritte;
}
public final void setzeNeuePostion( double x, double y, double z ) {
this.x = x;
this.y = y;
this.z = z;
}
// public methods
public void setFarbe(String farbe) {
this.farbe = farbe;
}
public String getFarbe() {
return this.farbe;
}
public String getPosition() {
return "x-Koordinate " + this.x + " y-Koordinate " + this.y + " z-Koordinate " + this.z;
}
public void getMetaDaten() {
System.out.println("Art: " + this.istEin());
System.out.println("Lage: " + this.getPosition());
System.out.println("Parameter: " + this.getParameter());
System.out.println("Volumen: " + this.berechneVolumen());
System.out.println("Oberfläche: " + this.berechneOberflaeche());
System.out.println("Farbe: " + this.getFarbe());
}
public double getX() {
return this.x;
}
public double getY() {
return this.y;
}
public double getZ() {
return this.z;
}
}