I created this enum:
public enum CoffeeSorts {
Coffee("Kaffee"), Espresso("Espresso"), Mocca("Mocca"), Cappuccino(
"Cappuccino"), LatteMacchiato("Latte Macchiato"), DoubleEspresso(
"doppelter Espresso");
private final String stringValue;
private CoffeeSorts(final String s) {
stringValue = s;
}
public String toString() {
return stringValue;
}
}
I tried the following way to use it
public ACoffee createCoffee(String type) {
switch (type) {
case CoffeeSorts.Cappuccino :
try {
return new ChocolateSprincles(new Cream(new Coffee()));
} catch (Exception e) {}
return null;
break;
case CoffeeSorts.LatteMacchiato :
try {
return new ...
}
.
.
.
}
It only gives me an Error saying "cannot convert from CoffeeSorts to String". Can you tell me what i did wrong?