From f70f07ffbd4c5a8ad9820eb17aa173cd1d3da112 Mon Sep 17 00:00:00 2001 From: SimonDHG <@> Date: Mon, 27 Nov 2023 17:18:31 +0100 Subject: [PATCH] Wo sind meine Fahrzeuge --- Auto.java | 35 +++++++---------------------------- Auto_alt.java | 31 +++++++++++++++++++++++++++++++ Fahrrad.java | 8 ++++++++ Fahrzeug.java | 32 ++++++++++++++++++++++++++++++++ Krankenwagen.java | 18 ++++++++++++++++++ Rennwagen.java | 7 +++++++ 6 files changed, 103 insertions(+), 28 deletions(-) create mode 100644 Auto_alt.java create mode 100644 Fahrrad.java create mode 100644 Fahrzeug.java create mode 100644 Krankenwagen.java create mode 100644 Rennwagen.java diff --git a/Auto.java b/Auto.java index 6998c42..ca60cce 100644 --- a/Auto.java +++ b/Auto.java @@ -1,31 +1,10 @@ -/** - * Beschreiben Sie hier die Klasse Auto. - * - * @author (Ihr Name) - * @version (eine Versionsnummer oder ein Datum) - */ -import java.util.Random; -public class Auto +class Auto extends Fahrzeug { - int raeder; - String farbe; - - public Auto(int r, String f){ - Random rand = new Random(); - raeder = rand.nextInt(8); - farbe = f; - } - - private void hupe(){ - System.out.println("Hup-Hup!"); - } - - public void setzeRaeder(int r){ - raeder = r; - } - - public void ausgabe(){ - System.out.println("Ich bin ein " + farbe + "es Auto!"); - } + public Auto(){ + super(140, 4); } + protected Auto(double m ){ + super (m, 4); +} +} \ No newline at end of file diff --git a/Auto_alt.java b/Auto_alt.java new file mode 100644 index 0000000..ca70c85 --- /dev/null +++ b/Auto_alt.java @@ -0,0 +1,31 @@ + +/** + * Beschreiben Sie hier die Klasse Auto. + * + * @author (Ihr Name) + * @version (eine Versionsnummer oder ein Datum) + */ +import java.util.Random; +public class Auto_alt +{ + int raeder; + String farbe; + + public Auto_alt(int r, String f){ + Random rand = new Random(); + raeder = rand.nextInt(8); + farbe = f; + } + + private void hupe(){ + System.out.println("Hup-Hup!"); + } + + public void setzeRaeder(int r){ + raeder = r; + } + + public void ausgabe(){ + System.out.println("Ich bin ein " + farbe + "es Auto!"); + } +} diff --git a/Fahrrad.java b/Fahrrad.java new file mode 100644 index 0000000..96c2edb --- /dev/null +++ b/Fahrrad.java @@ -0,0 +1,8 @@ + +public class Fahrrad extends Fahrzeug +{ + public Fahrrad(){ + super(30, 2); + + } +} diff --git a/Fahrzeug.java b/Fahrzeug.java new file mode 100644 index 0000000..6ca2177 --- /dev/null +++ b/Fahrzeug.java @@ -0,0 +1,32 @@ + +public class Fahrzeug +{ + private double position; + private double speed; + private double max; + private int wheels; + + public void bewege( double time){ + this.position += speed*time/60; + } + + public void setSpeed(double s ) { + this.speed = s; + if (this.speed > this.max) this.speed = this.max; + } + + public double getMaxSpeed(){ + return this.max; + } + + public int getWheelCount(){ + return this.wheels; + } + + public Fahrzeug(double m, int w){ + this.position = 0; + this.speed = 0; + this.max = m; + this.wheels = w; + } +} diff --git a/Krankenwagen.java b/Krankenwagen.java new file mode 100644 index 0000000..e48a35c --- /dev/null +++ b/Krankenwagen.java @@ -0,0 +1,18 @@ + + +public class Krankenwagen extends Auto +{ + private boolean blaulicht; + public Krankenwagen(){ + super(); + + blaulicht = false; + } + public void turnOn() + { + blaulicht = true; + } + public void turnOff(){ + blaulicht = false; + } +} diff --git a/Rennwagen.java b/Rennwagen.java new file mode 100644 index 0000000..5d8fba0 --- /dev/null +++ b/Rennwagen.java @@ -0,0 +1,7 @@ + +public class Rennwagen extends Auto +{ + public Rennwagen(){ + super(220); + } +}