package part1;

/**
 * A test class for making Players. This demonstrates how
 * a client could create players via the factories and then
 * use them.
 *
 * @author $Author: cdent $
 *
 * @version $Revision: 1.2 $
 *
 */
public class Human {
    public static void main(String[] args) {

	PlayerFactory factory;
	char input = 'x';

	// get something from the input to choose which
	// factory we are using
	if (args.length > 0) {
	    input = args[0].charAt(0);
	}

	/*
	 *  Make the factory
	 *
	 * aiee it's the dreaded switch statement
	 * thank goodness this part is supposed to be crap
	 *
	 */
	switch(input) {
	case 'd':
	    factory = new DVDFactory();
	    break;
	case 'v':
	    factory = new VHSFactory();
	    break;
	case 't':
	    factory = new TapeFactory();
	    break;
	case 'c':
	    factory = new CDFactory();
	    break;
	default:
	    factory = new DVDFactory();
	    break;
	}

	// make the context and commands
	PlayerContext context = factory.makeContext();
	PlayerCommand stopCommand = factory.makeCommand("stop", context);
	PlayerCommand playCommand = factory.makeCommand("play", context);
	PlayerCommand rewindCommand = factory.makeCommand("rewind", context);
	PlayerCommand fastCommand = factory.makeCommand("fastForward", context);
	
	// set the commands on the context
	context.setStopCommand(stopCommand);
	context.setPlayCommand(playCommand);
	context.setRewindCommand(rewindCommand);
	context.setFastForwardCommand(fastCommand);

	// display the framework
	context.show();

	// press the buttons, see the actions

    }

}
