I have a chunk of code in which i have 5,6 if else statements, so just wanted to know what will be the best suited way in my case to refactor it.
public class liquor {
public void drinkit(String type) {
if ("whisky".equals(type)) {
drink_with_water(String water, String whisky);
} elseif ("rum".equals(type)) {
drink_with_water_juice(String water, String juice, String rum);
} elseif ("wine".equals(type)) {
drink_neat(String wine);
}
.............
.............
}
}
Any thoughts will be appreciated.
Aucun commentaire:
Enregistrer un commentaire