37 lines
818 B
Java
37 lines
818 B
Java
|
class Getraenk1 {
|
||
|
|
||
|
private String typ;
|
||
|
|
||
|
private boolean kohlenSaeure;
|
||
|
private double liter;
|
||
|
private double preis;
|
||
|
|
||
|
public Getraenk1(String typ, boolean kohlenSauere, double liter, double preis) {
|
||
|
this.typ = typ;
|
||
|
this.kohlenSaeure = kohlenSauere;
|
||
|
this.liter = liter;
|
||
|
this.preis = preis;
|
||
|
|
||
|
}
|
||
|
|
||
|
public double getLiter() {
|
||
|
return liter;
|
||
|
}
|
||
|
|
||
|
public double getPreis() {
|
||
|
return preis;
|
||
|
}
|
||
|
|
||
|
public void setPreis(double preis) {
|
||
|
this.preis = preis;
|
||
|
}
|
||
|
|
||
|
public String toString() {
|
||
|
if (kohlenSaeure == true) {
|
||
|
return "\n-Drink:" + typ + "\n-Mit Kohlensäure" + "\n-" + liter + " liter\n-Preis: " + preis + "€";
|
||
|
} else {
|
||
|
return "\n-Drink:" + typ + "\n-Ohne Kohlensäure" + "\n-" + liter + " liter\n-Preis: " + preis + "€";
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|