Skip to content

Instantly share code, notes, and snippets.

@mickaelw
Created March 1, 2020 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mickaelw/2d58db3b400d9089f300c622cc85d54c to your computer and use it in GitHub Desktop.
Save mickaelw/2d58db3b400d9089f300c622cc85d54c to your computer and use it in GitHub Desktop.
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