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/Flummi.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/Flummi.java')
| -rw-r--r-- | Info/10/2/Baelle/BlueJ_Projekt/Flummi.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Info/10/2/Baelle/BlueJ_Projekt/Flummi.java b/Info/10/2/Baelle/BlueJ_Projekt/Flummi.java new file mode 100644 index 00000000..7ee870aa --- /dev/null +++ b/Info/10/2/Baelle/BlueJ_Projekt/Flummi.java @@ -0,0 +1,36 @@ +public class Flummi extends Ball { + double bounceFaktor; + + public Flummi(double neuerBounceFaktor) { + super(); + bounceFaktor = neuerBounceFaktor; + super.RadiusSetzen(20); + super.FarbeSetzen("gruen"); + } + + public Flummi(int x, int y, double neuerBounceFaktor) { + super(x, y); + bounceFaktor = neuerBounceFaktor; + super.RadiusSetzen(20); + super.FarbeSetzen("gruen"); + } + + public void Ausführen() { + // Der Flummi liegt + if (y == 600-radius && geschwindigkeit > 0) { + return; + } + // Der Flummi faellt + geschwindigkeit += BESCHLEUNIGUNG; // Beschleunigung + int ny = y + (int)geschwindigkeit; + if (ny >= 600-radius) { // Der Flummi ist aufgeschlagen + ny = 600-radius; + geschwindigkeit = -1 * bounceFaktor * geschwindigkeit; + } + + super.PositionSetzen(x, ny); + } + public void SonderTaste(int sondertaste) {} + public void Taste(char taste) {} + public void Geklickt(int x, int y , int anzahl) {} +} |
