Aufgaben
This commit is contained in:
63
Zimmermann, Sascha/Auto.java
Normal file
63
Zimmermann, Sascha/Auto.java
Normal file
@@ -0,0 +1,63 @@
|
||||
public class Auto {
|
||||
|
||||
// Anfang Attribute
|
||||
private String Farbe;
|
||||
private int leistung;
|
||||
private int anzTueren;
|
||||
private String Hersteller;
|
||||
// Ende Attribute
|
||||
|
||||
public Auto(String Farbe, int leistung, int anzTueren, String Hersteller) {
|
||||
this.Farbe = Farbe;
|
||||
this.leistung = leistung;
|
||||
this.anzTueren = anzTueren;
|
||||
this.Hersteller = Hersteller;
|
||||
}
|
||||
|
||||
// Anfang Methoden
|
||||
public String getFarbe() {
|
||||
return Farbe;
|
||||
}
|
||||
|
||||
public void setFarbe(String FarbeNeu) {
|
||||
Farbe = FarbeNeu;
|
||||
}
|
||||
|
||||
public int getLeistung() {
|
||||
return leistung;
|
||||
}
|
||||
|
||||
public void setLeistung(int leistungNeu) {
|
||||
leistung = leistungNeu;
|
||||
}
|
||||
|
||||
public int getAnzTueren() {
|
||||
return anzTueren;
|
||||
}
|
||||
|
||||
public void setAnzTueren(int anzTuerenNeu) {
|
||||
anzTueren = anzTuerenNeu;
|
||||
}
|
||||
|
||||
public String getHersteller() {
|
||||
return Hersteller;
|
||||
}
|
||||
|
||||
public void setHersteller(String HerstellerNeu) {
|
||||
Hersteller = HerstellerNeu;
|
||||
}
|
||||
|
||||
public void tuning(int leistungNeu) {
|
||||
double leistungMax = leistung * 0.2;
|
||||
|
||||
if(leistungNeu < leistungMax){
|
||||
leistung += leistungNeu;
|
||||
System.out.println("Das Tuning wurde durchgeführt, das Auto hat jetzt " + leistung + "PS");
|
||||
}
|
||||
else{
|
||||
System.out.println("Das Tuning übersteigt die Möglichkeiten des Fahrzeugs. Es können maximal " + leistungMax + "PS hinzukommen!");
|
||||
}
|
||||
}
|
||||
|
||||
// Ende Methoden
|
||||
} // end of Auto
|
||||
Reference in New Issue
Block a user