Skip to content

Commit

Permalink
Create Polymorphism
Browse files Browse the repository at this point in the history
  • Loading branch information
Naveenkumarsahu9795 authored Oct 3, 2023
1 parent 6621625 commit 32efeb5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Polymorphism
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
public class BasicCoffeeMachine {
//Naveen PM
public Coffee brewCoffee(CoffeeSelection selection) throws CoffeeException {
switch (selection) {
case FILTER_COFFEE:
return brewFilterCoffee();
default:
throw new CoffeeException(
"CoffeeSelection ["+selection+"] not supported!");
}
}

public List brewCoffee(CoffeeSelection selection, int number) throws CoffeeException {
List coffees = new ArrayList(number);
for (int i=0; i<number; i++) {
coffees.add(brewCoffee(selection));
}
return coffees;
}
}

0 comments on commit 32efeb5

Please sign in to comment.