Skip to content

Instantly share code, notes, and snippets.

@digitsensitive
Last active August 4, 2020 18:35
Show Gist options
  • Select an option

  • Save digitsensitive/00f67c1cb1675702a4d84053f65d8587 to your computer and use it in GitHub Desktop.

Select an option

Save digitsensitive/00f67c1cb1675702a4d84053f65d8587 to your computer and use it in GitHub Desktop.
export class SimpleEnemyFactory {
public create(enemyType: string): Enemy {
switch (enemyType) {
case "bobbie":
return new Bobbie();
case "wallace":
return new Wallace();
case "kanye":
return new Kanye();
default:
// Oops, no Enemy of this type!
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment