Created
November 9, 2016 21:23
-
-
Save chermehdi/dd15b18b14fd737c189ba6f2a77cf9d2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public class EnemyFactory { | |
public static Enemy create(EnemyType enemyType) { | |
Enemy enemy = null; | |
switch (enemyType) { | |
case SMALLENEMY: | |
enemy = new SmallEnemy(); | |
break; | |
case SMARTENEMY: | |
enemy = new SmartEnemy(); | |
break; | |
default: | |
// throw some kind of exception | |
throw new RuntimeException("the given enemy type does not existe "); | |
} | |
return enemy; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment