1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
|
public class Cocktail {
private String spirituose;
private String saft;
private boolean enthaeltSahne; //Rechtschreibung korrigiert
private boolean enthaeltAlkohol;
private boolean enthaeltKokos; //Rechtschreibung korrigiert
public Cocktail(String spirituose, String saft, boolean enhaeltSahne,
boolean enthaeltAlkohol, boolean entaeltKokos) {
this.spirituose = spirituose;
this.saft = saft;
this.enthaeltSahne = enhaeltSahne;
this.enthaeltAlkohol = enthaeltAlkohol;
this.enthaeltKokos = entaeltKokos;
}
public static void main(String[] args) {
Cocktail c1 = new Cocktail("Rum", "Ananas", true, true, true);
System.out.println(c1.ermittleBezeichnung());
Cocktail c2 = new Cocktail(" ", "Ananas", true, false, true);
System.out.println(c2.ermittleBezeichnung());
}
public String ermittleBezeichnung() {
String bezeichnung = "";
//Auskommentiert
// boolean enthaeltSahne = false;
// boolean enthaeltAlkohol = false;
// boolean enthaeltKokos = false;
if (spirituose.equals("Rum") && (saft.equals("Ananas"))
&& (enthaeltSahne == true) && (enthaeltAlkohol == true)
&& (enthaeltKokos == true)) {
bezeichnung = "Pina Colada";
return bezeichnung;
}
if (spirituose.equals(" ")
&& (saft.equals("Ananas"))
&& (enthaeltSahne == true && enthaeltAlkohol == false && enthaeltKokos == true)) {
bezeichnung = "Virgin Colada";
return bezeichnung;
} else {
bezeichnung = "Anderer Cocktail";
return bezeichnung;
}
}
} |