I have a base class called Enemy and various subclasses that are of type Enemy such as BigEnemy, LazerEnemy, AvoidingEnemy etc.
I have a Formation class whose purpose is to create specialized formations of enemies, such as line, grid, pyramid.
I would like Formation to take in as a parameter what type of Subclass of Enemy I want to create.
Formation f = new Formation("LazerEnemy","triangle", 4); // makes a triangle formation of lazer enmies
Formation f = new Formation("BigEnemy","line", 10); // makes a line of big enemies
Currently I was going to do something like pass a string called enemyType (or it could be just an integer and do switch statements), but since I have so many enemy types I was wondering if there was a neater way to pass the type of the object I want to instantiate that doesn't need to use a switch statement.
Perhaps this has something to do with Factory and this question, but I don't quite understand it.
Thanks