import javax.swing.undo.*;

/**
 * An (undoable) change to a YardMarker
 *
 * @version 1.0
 * @author  Prof. David Benrstein, James Madison University
 */
public class YardMarkerEdit extends AbstractUndoableEdit
{
    private int          down,    toGo,    yard;
    private int          oldDown, oldToGo, oldYard;
    private String       side;
    private String       oldSide;
    private YardMarker   ym;

    /**
     * Explicit Value Constructor
     */
    public YardMarkerEdit(YardMarker ym,
			  int down, int toGo, String side, int yard)
    {
	super();

	this.ym   = ym;

	this.down = down;
	this.toGo = toGo;
	this.side = side;
	this.yard = yard;

	oldDown   = ym.getDown();
	oldToGo   = ym.getToGo();
	oldSide   = ym.getSide();
	oldYard   = ym.getYard();

	ym.setValues(down, toGo, side, yard);
    }


    /**
     * Get a description of this edit
     */
    public String getPresentationName()
    {
	return ""+down+" and "+toGo+" on "+side+" "+yard;
    }

    /**
     * Redo this edit
     */
    public void redo() throws CannotUndoException
    {
	super.redo(); // Sets hasBeenDone to true
	
	ym.setValues(down, toGo, side, yard);
    }



    /**
     * Redo this edit
     */
    public void undo() throws CannotUndoException
    {
	super.undo(); // Sets hasBeenDone to false

	ym.setValues(oldDown, oldToGo, oldSide, oldYard);
    }
}
