package part1;

import java.util.Map;
import java.util.HashMap;


/**
 *
 * @author $Author: cdent $
 *
 * @version $Revision: 1.1.1.1 $
 *
 */
public class CDFactory implements PlayerFactory {

    Map commandMap = new HashMap();

    public CDFactory() {
	commandMap.put("play", new CDPlayCommand());
	commandMap.put("stop", new CDStopCommand());
	commandMap.put("fastForward", new CDFastForwardCommand());
	commandMap.put("rewind", new CDRewindCommand());
	
    }
    
    public PlayerCommand makeCommand(String command, PlayerContext context) {
	PlayerCommand playerCommand = (PlayerCommand)commandMap.get(command);
	PlayerCommand newPlayerCommand = (PlayerCommand)playerCommand.clone();
	newPlayerCommand.setContext(context);
	newPlayerCommand.init();
	return newPlayerCommand;
    }

    public PlayerContext makeContext() {
	return new CDContext();
    }
}

    
