package part1;

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


/**
 *
 * Factory for creating a VHSPlayer
 *
 * @author $Author: cdent $
 *
 * @version $Revision: 1.2 $
 *
 */
public class VHSFactory implements PlayerFactory {

    Map commandMap = new HashMap();

    public VHSFactory() {
	commandMap.put("play", new VHSPlayCommand());
	commandMap.put("stop", new VHSStopCommand());
	commandMap.put("fastForward", new VHSFastForwardCommand());
	commandMap.put("rewind", new VHSRewindCommand());
	
    }

    public PlayerCommand makeCommand(String command, PlayerContext context) {
	PlayerCommand playerCommand = (PlayerCommand)commandMap.get(command);
	PlayerCommand newPlayerCommand = (PlayerCommand)playerCommand.clone();
	newPlayerCommand.setContext(context);
	// create the buttons
	newPlayerCommand.init();
	return newPlayerCommand;
    }

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

    
