package part1;

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


/**
 * Factory for creating Tape Players
 *
 * @author $Author: cdent $
 *
 * @version $Revision: 1.2 $
 *
 */
public class TapeFactory implements PlayerFactory {

    Map commandMap = new HashMap();

    public TapeFactory() {
	commandMap.put("play", new TapePlayCommand());
	commandMap.put("stop", new TapeStopCommand());
	commandMap.put("fastForward", new TapeFastForwardCommand());
	commandMap.put("rewind", new TapeRewindCommand());
	
    }

    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 TapeContext();
    }
}

    
