From: Robin Cheney Date: Fri, 7 Nov 2025 08:12:33 +0000 (+0100) Subject: Reimplemented inheritants of Tankstelle (less problematic than I thought it would... X-Git-Url: https://git.eternal.ddnss.de/?a=commitdiff_plain;h=2937b621d9cfa2aa4424de94607fe522f2ea4050;p=tankstelle.git Reimplemented inheritants of Tankstelle (less problematic than I thought it would be later on) --- diff --git a/src/main/java/de/tankstelle/GrosseTankstelle.java b/src/main/java/de/tankstelle/GrosseTankstelle.java index dfce86f..cc07887 100644 --- a/src/main/java/de/tankstelle/GrosseTankstelle.java +++ b/src/main/java/de/tankstelle/GrosseTankstelle.java @@ -1,16 +1,25 @@ package de.tankstelle; -// public class GrosseTankstelle extends Tankstelle { -// private String betreiberfirma_supermarkt; +public class GrosseTankstelle extends Tankstelle { + private String betreiberfirma_supermarkt; -// public GrosseTankstelle(String betreiberfirma_supermarkt) { -// Treibstoff[] treibstoffe = { new Treibstoff(Treibstofftyp.SUPER, 8000f, 0f, 16000), -// new Treibstoff(Treibstofftyp.SUPER_E10, 8000f, 0f, 16000), -// new Treibstoff(Treibstofftyp.DIESEL, 8000f, 0f, 16000), -// new Treibstoff(Treibstofftyp.PREMIUM_DIESEL, 8000f, 0f, 16000), -// new Treibstoff(Treibstofftyp.AUTOGAS, 8000f, 0f, 16000) }; -// super((byte) 4, treibstoffe); + public GrosseTankstelle(String betreiberfirma_supermarkt) { + Treibstoff[] treibstoffe = { new Treibstoff(Treibstofftyp.SUPER, 8000f, 0f, 16000), + new Treibstoff(Treibstofftyp.SUPER_E10, 8000f, 0f, 16000), + new Treibstoff(Treibstofftyp.DIESEL, 8000f, 0f, 16000), + new Treibstoff(Treibstofftyp.PREMIUM_DIESEL, 8000f, 0f, 16000), + new Treibstoff(Treibstofftyp.AUTOGAS, 8000f, 0f, 16000) }; + super((byte) 4, Groesse.GROSS, treibstoffe); + this.betreiberfirma_supermarkt = betreiberfirma_supermarkt; + } -// this.betreiberfirma_supermarkt = betreiberfirma_supermarkt; -// } -// } + public GrosseTankstelle(String betreiberfirma_supermarkt, byte mitarbeiterzahl) { + Treibstoff[] treibstoffe = { new Treibstoff(Treibstofftyp.SUPER, 8000f, 0f, 16000), + new Treibstoff(Treibstofftyp.SUPER_E10, 8000f, 0f, 16000), + new Treibstoff(Treibstofftyp.DIESEL, 8000f, 0f, 16000), + new Treibstoff(Treibstofftyp.PREMIUM_DIESEL, 8000f, 0f, 16000), + new Treibstoff(Treibstofftyp.AUTOGAS, 8000f, 0f, 16000) }; + super(mitarbeiterzahl, Groesse.GROSS, treibstoffe); + this.betreiberfirma_supermarkt = betreiberfirma_supermarkt; + } +} diff --git a/src/main/java/de/tankstelle/KleineTankstelle.java b/src/main/java/de/tankstelle/KleineTankstelle.java index 6c1088a..6ae76aa 100644 --- a/src/main/java/de/tankstelle/KleineTankstelle.java +++ b/src/main/java/de/tankstelle/KleineTankstelle.java @@ -1,12 +1,19 @@ -// package de.tankstelle; +package de.tankstelle; -// public class KleineTankstelle extends Tankstelle { -// private short anzahl_getraenkeautomaten; +public class KleineTankstelle extends Tankstelle { + private short anzahl_getraenkeautomaten; -// public KleineTankstelle(short anzahl_getraenkeautomaten) { -// Treibstoff[] treibstoffe = { new Treibstoff(Treibstofftyp.SUPER, 4000f, 0f, 8000), -// new Treibstoff(Treibstofftyp.DIESEL, 4000f, 0f, 8000) }; -// super((byte) 4, treibstoffe); -// this.anzahl_getraenkeautomaten = anzahl_getraenkeautomaten; -// } -// } + public KleineTankstelle(short anzahl_getraenkeautomaten) { + Treibstoff[] treibstoffe = { new Treibstoff(Treibstofftyp.SUPER, 4000f, 0f, 8000), + new Treibstoff(Treibstofftyp.DIESEL, 4000f, 0f, 8000) }; + super((byte) 1, Groesse.KLEIN, treibstoffe); + this.anzahl_getraenkeautomaten = anzahl_getraenkeautomaten; + } + + public KleineTankstelle(short anzahl_getraenkeautomaten, byte mitarbeiterzahl) { + Treibstoff[] treibstoffe = { new Treibstoff(Treibstofftyp.SUPER, 4000f, 0f, 8000), + new Treibstoff(Treibstofftyp.DIESEL, 4000f, 0f, 8000) }; + super(mitarbeiterzahl, Groesse.KLEIN, treibstoffe); + this.anzahl_getraenkeautomaten = anzahl_getraenkeautomaten; + } +} diff --git a/src/main/java/de/tankstelle/Main.java b/src/main/java/de/tankstelle/Main.java index b048731..280f0a3 100644 --- a/src/main/java/de/tankstelle/Main.java +++ b/src/main/java/de/tankstelle/Main.java @@ -1,7 +1,12 @@ package de.tankstelle; public class Main { - public static void main(String[] args) { + static Tankstelle[] tankstellen = { new KleineTankstelle((short) 0), new KleineTankstelle((short) 0), + new MittlereTankstelle(0), new MittlereTankstelle(0), new MittlereTankstelle(0), + new GrosseTankstelle("PlatzhalterFirma1"), new GrosseTankstelle("PlatzhalterFirma2"), + new GrosseTankstelle("PlatzhalterFirma3") }; + + public static void main(String[] args) { } } \ No newline at end of file diff --git a/src/main/java/de/tankstelle/MittlereTankstelle.java b/src/main/java/de/tankstelle/MittlereTankstelle.java index 06f7da8..039e725 100644 --- a/src/main/java/de/tankstelle/MittlereTankstelle.java +++ b/src/main/java/de/tankstelle/MittlereTankstelle.java @@ -1,14 +1,23 @@ -// package de.tankstelle; +package de.tankstelle; -// public class MittlereTankstelle extends Tankstelle { -// private short quadratmeterzahl_verkaufsflaeche; +public class MittlereTankstelle extends Tankstelle { + private int quadratmeterzahl_verkaufsflaeche; -// public MittlereTankstelle(short quadratmeterzahl_verkaufsflaeche) { -// Treibstoff[] treibstoffe = { new Treibstoff(Treibstofftyp.SUPER, 6000f, 0f, 12000), -// new Treibstoff(Treibstofftyp.SUPER_E10, 6000f, 0f, 12000), -// new Treibstoff(Treibstofftyp.PREMIUM_DIESEL, 6000f, 0f, 12000), -// new Treibstoff(Treibstofftyp.AUTOGAS, 6000f, 0f, 12000) }; -// super((byte) 4, treibstoffe); -// this.quadratmeterzahl_verkaufsflaeche = quadratmeterzahl_verkaufsflaeche; -// } -// } + public MittlereTankstelle(int quadratmeterzahl_verkaufsflaeche) { + Treibstoff[] treibstoffe = { new Treibstoff(Treibstofftyp.SUPER, 6000f, 0f, 12000), + new Treibstoff(Treibstofftyp.SUPER_E10, 6000f, 0f, 12000), + new Treibstoff(Treibstofftyp.PREMIUM_DIESEL, 6000f, 0f, 12000), + new Treibstoff(Treibstofftyp.AUTOGAS, 6000f, 0f, 12000) }; + super((byte) 2, Groesse.MITTEL, treibstoffe); + this.quadratmeterzahl_verkaufsflaeche = quadratmeterzahl_verkaufsflaeche; + } + + public MittlereTankstelle(int quadratmeterzahl_verkaufsflaeche, byte mitarbeiterzahl) { + Treibstoff[] treibstoffe = { new Treibstoff(Treibstofftyp.SUPER, 6000f, 0f, 12000), + new Treibstoff(Treibstofftyp.SUPER_E10, 6000f, 0f, 12000), + new Treibstoff(Treibstofftyp.PREMIUM_DIESEL, 6000f, 0f, 12000), + new Treibstoff(Treibstofftyp.AUTOGAS, 6000f, 0f, 12000) }; + super(mitarbeiterzahl, Groesse.MITTEL, treibstoffe); + this.quadratmeterzahl_verkaufsflaeche = quadratmeterzahl_verkaufsflaeche; + } +} diff --git a/src/main/java/de/tankstelle/Tankstelle.java b/src/main/java/de/tankstelle/Tankstelle.java index 969155e..aaa7620 100644 --- a/src/main/java/de/tankstelle/Tankstelle.java +++ b/src/main/java/de/tankstelle/Tankstelle.java @@ -10,43 +10,22 @@ public class Tankstelle { */ private Treibstoff[] treibstoffe; - private int quadratmeterzahl_verkaufsflaeche; - - private short anzahl_getraenkeautomaten; - - private String betreiberfirma_supermarkt; - + /** + * Größe der Tankstelle. Ist eher dekorativ, da man das auch über den Objekttyp + * (KleineTankstelle | MittlereTankstelle | GrosseTankstelle) + * auslesen kann. + */ private Groesse groesse; - private Tankstelle(byte mitarbeiterzahl, Groesse groesse, Treibstoff[] treibstoffe) { + /** + * Protected Superconstructor + * @param mitarbeiterzahl + * @param groesse + * @param treibstoffe + */ + protected Tankstelle(byte mitarbeiterzahl, Groesse groesse, Treibstoff[] treibstoffe) { this.mitarbeiterzahl = mitarbeiterzahl; this.groesse = groesse; this.treibstoffe = treibstoffe; } - - public Tankstelle(byte mitarbeiterzahl, String betreiberfirma_supermarkt) { - Treibstoff[] treibstoffe = { new Treibstoff(Treibstofftyp.SUPER, 8000f, 0f, 16000), - new Treibstoff(Treibstofftyp.SUPER_E10, 8000f, 0f, 16000), - new Treibstoff(Treibstofftyp.DIESEL, 8000f, 0f, 16000), - new Treibstoff(Treibstofftyp.PREMIUM_DIESEL, 8000f, 0f, 16000), - new Treibstoff(Treibstofftyp.AUTOGAS, 8000f, 0f, 16000) }; - this(mitarbeiterzahl, Groesse.GROSS, treibstoffe); - this.betreiberfirma_supermarkt = betreiberfirma_supermarkt; - } - - public Tankstelle(byte mitarbeiterzahl, int quadratmeterzahl_verkaufsflaeche) { - Treibstoff[] treibstoffe = { new Treibstoff(Treibstofftyp.SUPER, 6000f, 0f, 12000), - new Treibstoff(Treibstofftyp.SUPER_E10, 6000f, 0f, 12000), - new Treibstoff(Treibstofftyp.PREMIUM_DIESEL, 6000f, 0f, 12000), - new Treibstoff(Treibstofftyp.AUTOGAS, 6000f, 0f, 12000) }; - this(mitarbeiterzahl, Groesse.MITTEL, treibstoffe); - this.quadratmeterzahl_verkaufsflaeche = quadratmeterzahl_verkaufsflaeche; - } - - public Tankstelle(byte mitarbeiterzahl, short anzahl_getraenkeautomaten) { - Treibstoff[] treibstoffe = { new Treibstoff(Treibstofftyp.SUPER, 4000f, 0f, 8000), - new Treibstoff(Treibstofftyp.DIESEL, 4000f, 0f, 8000) }; - this(mitarbeiterzahl, Groesse.KLEIN, treibstoffe); - this.anzahl_getraenkeautomaten = anzahl_getraenkeautomaten; - } }