diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2024-05-05 14:36:59 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2024-05-05 14:36:59 +0200 |
| commit | aed3ad2011483d36b1f6f6b772a6f300cb967cc0 (patch) | |
| tree | 7f1543b344bdd783db1d5b079dbd15b3e6a0bf34 /Info/10/2/Baelle/BlueJ_Projekt/Ball.java | |
| parent | a91e3342f58a6476e17d9bd172f02b1c7cacf603 (diff) | |
| download | unterricht-aed3ad2011483d36b1f6f6b772a6f300cb967cc0.tar.gz unterricht-aed3ad2011483d36b1f6f6b772a6f300cb967cc0.zip | |
add Baelle project for simple inheritance
Diffstat (limited to 'Info/10/2/Baelle/BlueJ_Projekt/Ball.java')
| -rw-r--r-- | Info/10/2/Baelle/BlueJ_Projekt/Ball.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Info/10/2/Baelle/BlueJ_Projekt/Ball.java b/Info/10/2/Baelle/BlueJ_Projekt/Ball.java new file mode 100644 index 00000000..61c92965 --- /dev/null +++ b/Info/10/2/Baelle/BlueJ_Projekt/Ball.java @@ -0,0 +1,33 @@ +public class Ball extends Kreis implements Zeichenfenster.AktionsEmpfaenger { + static final double BESCHLEUNIGUNG = 5; + double geschwindigkeit = 0; + + public Ball() { + super(); + Zeichenfenster.AktionsEmpfängerEintragen(this); + } + + public Ball(int x, int y) { + this(); + super.PositionSetzen(x, y); + } + + public void Ausführen() { + // Der Ball liegt + if (y == 600-radius) { + return; + } + // Der Ball faellt + geschwindigkeit += BESCHLEUNIGUNG; // Beschleunigung + int ny = y + (int)geschwindigkeit; + if (ny >= 600-radius) { // Der Ball ist aufgeschlagen + ny = 600-radius; + geschwindigkeit = 0; + } + + super.PositionSetzen(x, ny); + } + public void SonderTaste(int sondertaste) {} + public void Taste(char taste) {} + public void Geklickt(int x, int y , int anzahl) {} +} |
