Bruno
Bruno

Reputation: 89

Variable as the name of a class

How can you use a variable as a name for a class? I want to make the name of the class flexible.

var number = 1 ;

return MechanikGameStart$number();

Upvotes: 0

Views: 80

Answers (1)

dm_tr
dm_tr

Reputation: 4763

if (1 == number) return MechanikGameStart1();
else if (2 == number) return MechanikGameStart2();
// ...

Otherwise it's not possible in Object-oriented programming. Class name must be known and specified in advance

Upvotes: 5

Related Questions