Created
March 1, 2020 10:25
-
-
Save mickaelw/2d58db3b400d9089f300c622cc85d54c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class DiscountCalculatorFactory { | |
static for(numberOfSameBook: number): DiscountCalculator { | |
switch (numberOfSameBook) { | |
case 1: | |
return new NoDiscountCalculator() | |
case 2: | |
return new TwoSameBooksDiscountCalculator() | |
default: | |
return new ThreeOrMoreSameBooksDiscountCalculator() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment