Last active
July 16, 2019 08:07
-
-
Save jtuttas/e791c37632b54045ffd5 to your computer and use it in GitHub Desktop.
Aufgabe 6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Auszug aus der Klasse OBJTraining | |
System.out.println("Ich besitze insgesammt " | |
+ Fahrzeugmarke.getNumberOfProducts() + " Produkte"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dq.fiae12e; | |
public class Fahrzeugmarke extends Fahrzeug { | |
private double preis; | |
private String hersteller; | |
private static int numberOfProduct=0; | |
public Fahrzeugmarke(double gewicht) { | |
super(gewicht); | |
numberOfProduct++; | |
// TODO Auto-generated constructor stub | |
} | |
public Fahrzeugmarke(double gewicht, long laufleistung) { | |
super(gewicht, laufleistung); | |
numberOfProduct++; | |
// TODO Auto-generated constructor stub | |
} | |
public static int getNumberOfProducts() { | |
return numberOfProduct; | |
} | |
public double getPreis() { | |
return preis; | |
} | |
public void setPreis(double preis) { | |
/** | |
* Lange Form | |
*/ | |
/* | |
if (preis<=0) { | |
this.preis=0; | |
} | |
else { | |
this.preis = preis; | |
} | |
*/ | |
this.preis=(preis<=0.0 ? 0 : preis); | |
} | |
public String getHersteller() { | |
return hersteller; | |
} | |
public void setHersteller(String hersteller) { | |
this.hersteller = hersteller; | |
} | |
public String toString() { | |
// TODO Auto-generated method stub | |
return "Name="+hersteller+" Preis="+preis+" "+super.toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment