import std.stdio;

abstract class Command
{
	void execute();
}

class Class0 : Command
{
	void execute() { writefln("Class0"); }
}

class Class1 : Command
{
	void execute() { writefln("Class1"); }
}

class Class2 : Command
{
	void execute() { writefln("Class2"); }
}

alias Command delegate() CommandFactory;

void main()
{
	CommandFactory[] commands = [ 
		delegate() { return cast(Command)(new Class0()); },
		delegate() { return cast(Command)(new Class1()); },
		delegate() { return cast(Command)(new Class0()); },
	];
	
	int selected = 1;
	Command command = commands[selected]();
	command.execute();
}