/**
* Beschreiben Sie hier die Klasse Auto.
*
* @author (Kerstin Fröhlig)
* @version (Version 1 Dezember 2017) */
public class Auto {
// Instanzvariablen - ersetzen Sie das folgende Beispiel mit Ihren Variablen private String autoModell;
private double autoTankinhalt;
private double autoVerbrauch;
private double autoTankgroesse;
/**
* Konstruktor für Objekte der Klasse Auto */
public Auto(String aMod, double aTInhalt,double aVerb, double aTGroesse ) {
autoVerbrauch= aVerb;
autoModell=aMod;
autoTankgroesse=aTGroesse;
autoTankinhalt = aTInhalt;
}
public double getTankinhalt() {
return autoTankinhalt;
}
public double getVerbrauch() {
return autoVerbrauch;
}
private void setTankinhalt(double liter) {
autoTankinhalt = autoTankinhalt - liter;
} /**
* Fahren: Eingabe Anzahl Kilometer */
public double fahren(int kilometer) {
double verbrauch;
double tankinhalt1;
double tankinhalt2;
verbrauch=getVerbrauch()*kilometer/100;
System.out.println("Für "+kilometer+" wird soviel Benzin benötigt: " +verbrauch+ " Liter ");
tankinhalt1=getTankinhalt();
System.out.println("Soviel ist noch drin: " + tankinhalt1);
if (verbrauch<tankinhalt1) setTankinhalt(verbrauch) ;
else System.out.println("Das Benzin reicht nicht.");
return autoTankinhalt;
}
public double tanken() {
double getankteL;
if (autoTankinhalt<autoTankgroesse*0.8) {getankteL=autoTankgroesse-autoTankinhalt;
autoTankinhalt =autoTankgroesse ; }
else
{System.out.println("Tanken ist noch nicht nötig.");
getankteL=0;}
System.out.println("So viel wurde getankt" +getankteL);
return getankteL;
} }