Skip to content

Instantly share code, notes, and snippets.

@jtuttas
Last active July 16, 2019 08:07
Show Gist options
  • Save jtuttas/e791c37632b54045ffd5 to your computer and use it in GitHub Desktop.
Save jtuttas/e791c37632b54045ffd5 to your computer and use it in GitHub Desktop.
Aufgabe 6
// Auszug aus der Klasse OBJTraining
System.out.println("Ich besitze insgesammt "
+ Fahrzeugmarke.getNumberOfProducts() + " Produkte");
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