jtuttas
11/14/2014 - 11:01 AM

Aufgabe 6

Aufgabe 6

package dq.fiae12e;

public class Produkt extends Fahrzeug {
	private double preis;
	private String hersteller;
	private static int numberOfProduct=0;
	
	public Produkt(double gewicht) {
		super(gewicht);
		numberOfProduct++;
		// TODO Auto-generated constructor stub
	}

	public Produkt(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();
	}

	
}
// Auszug aus der Klasse OBJTraining

System.out.println("Ich besitze insgesammt "
				+ Produkt.getNumberOfProducts() + " Produkte");