package calc;

/** Sum three registers
 * @author Gary T. Leavens
 */
public class Sum3 extends Sum {
    
    /** The third register to sum. */
    private /*@ spec_public @*/ int reg3;
    
    /**
     * Initialize this Sum object to calculate 
     * the sum of the given registers.
    */
    public Sum3(int reg1, int reg2, int reg3) {
        super(reg1, reg2);
        this.reg3 = reg3;
    }
    
    /**
     * Evaluate the formula and return its value.
     */
    /*@ also
      @   ensures (* \result is the sum of the value of
      @              all the register's values. *); @*/
    public double evaluate() {
        return super.evaluate() + Registers.get(reg3);
    }

}
