/* $Id$
 */
package calc;

/** Triple summation formulas for the calculator.
 * @author Gary T. Leavens
 */
public class Sum3 extends Sum {
	/** the third register */
	private int reg3;

    /**
     * Initialize this Formula object to be the sum
     * of the given registers.
     * @param reg1 the first register's number.
     * @param reg2 the second register's number
     * @param reg3 the third register's number
     */
    //@ requires 0 <= reg1 && reg1 < Registers.NUM_REGS;
	//@ requires 0 <= reg2 && reg2 < Registers.NUM_REGS;
	//@ requires 0 <= reg3 && reg3 < Registers.NUM_REGS;
    //@ ensures this.left == reg1 && this.right == reg2;
    //@ ensures this.reg3 == reg3; 
    public Sum3(int reg1, int reg2, int reg3) {
        super(reg1, reg2);
        this.reg3 = reg3;
    }

    // documentation comment and specification inherited
    public double evaluate() {
        return super.evaluate() + get(reg3);
    }

}
