-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBall.java
More file actions
191 lines (161 loc) · 4.59 KB
/
Copy pathBall.java
File metadata and controls
191 lines (161 loc) · 4.59 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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/**
* Klasse Ball zum Erkunden von Attributen und Methoden
*
* @author mike_gans@yahoo.de
*
* @version 4.0 (2018-08-07)
*
*/
public class Ball
extends KREIS
{
private float reibung;
private float elastizitaet;
private float masse;
private String farbe;
/**
* Konstruktor der Klasse Ball
*
* @param x x-Koordinate des Mittelpunkts
* @param y y-Koordinate des Mittelpunkts
*/
public Ball( float x , float y )
{
super( 25 );
super.setzeFarbe( "blau");
super.macheAktiv();
this.masse = 1f;
setzeMasse( this.masse );
this.farbe = super.nenneFarbe();
this.reibung = 0.1f;
super.setzeReibung( this.reibung );
this.elastizitaet = 0.5f;
super.setzeElastizitaet( this.elastizitaet );
super.setzeMittelpunkt( x , y );
}
/**
* Konstruktor der Klasse Ball
*
* @param kg Masse des Balls in kg
* @param radius Radius des Balls in Pixel am Bildschirm
*/
public Ball ( int radius )
{
this( 0 , 100 );
super.setzeRadius( radius );
super.macheAktiv();
this.elastizitaet = 0.5f;
super.setzeElastizitaet( this.elastizitaet );
this.reibung = 0.1f;
super.setzeReibung( this.reibung );
}
/**
* Legt den Ball an den entsprechenden Koordinaten ab.
*
* @param x x-Koordinate
* @param y y-Koordinate
*/
public void setzeMittelpunkt( float x , float y )
{
super.setzeGeschwindigkeit( 0 , 0 );
super.setzeMittelpunkt( x , y );
}
/**
* Setzt die Geschwindigkeit des Balls auf einen bestimmten Wert.
* Liegt der Ball still, so entspricht das einem "Tritt" in diese Richtung.
*
* @param inXrichtung Geschwindigkeit in x-Richtung
* @param inYrichtung Geschwindigkeit in y-Richtung
*/
public void setzeGeschwindigkeit( float inXrichtung , float inYrichtung )
{
//this.geschwindigkeitX = inXrichtung;
//this.geschwindigkeitY = inYrichtung;
super.setzeGeschwindigkeit( inXrichtung , inYrichtung );
}
/**
* Nennt die aktuelle Geschwindigkeit in x-Richtung.
*
* @return aktuelle Geschwindigktei in x-Richtung
*/
public float nenneGeschwindigkteiX()
{
//this.geschwindigkeitX = super.nenneVx();
//this.geschwindigkeitY = super.nenneVy();
return super.nenneVx();
}
/**
* Nennt die aktuelle Geschwindigkeit in y-Richtung.
*
* @return aktuelle Geschwindigktei in y-Richtung
*/
public float nenneGeschwindigkteiY()
{
//this.geschwindigkeitX = super.nenneVx();
//this.geschwindigkeitY = super.nenneVy();
return super.nenneVy();
}
/**
* Setzt den Reibungs-Koeffizienten des Balls beim Rollen auf dem Boden.
*
* @param reibungsKoeffizient 0=keine Reibung ; 0.5=standard
*/
public void setzeReibung( float reibungsKoeffizient )
{
this.reibung = reibungsKoeffizient;
super.setzeReibung( reibungsKoeffizient );
}
/**
* Gibt den aktuellen Reibungs-Koeffizienten des Balls zurueck.
*
* @return aktueller Reibungs-Koeffizienten des Balls
*/
public float nenneReibung()
{
return this.reibung;
}
/**
* Setzt die Elastizitaet des Balls auf eienen bestimmten Wert.
*
*
* @param elastizitaetsKonstante 0 = steinhart ; 0.5 = standard ; 1 = reibungsfreier Gummihuepfer
*/
public void setzeElastizitaet( float elastizitaetsKonstante )
{
this.elastizitaet = elastizitaetsKonstante;
super.setzeElastizitaet( elastizitaetsKonstante );
}
/**
* Gibt die aktuelle Elastizitaets-Konstante des Balls zurueck.
*
* @return aktuelle Elastizitaets-Konstante des Balls
*/
public float nenneElastizitaet()
{
return this.elastizitaet;
}
/**
* Setzt die Masse des Balls in kg
*
* @param kg neue Masse des Balls
*/
public void setzeMasse( float kg )
{
this.masse = kg;
super.setzeMasse( kg );
}
/**
* Nennt die aktuelle Masse des Balls
*
* @return aktuelle Masse des Balls
*/
public float nenneMasse()
{
return this.masse;
}
public void setzeFarbe( String farbe )
{
this.farbe = farbe;
super.setzeFarbe( farbe );
}
}