package calc;

/** Storage for the registers of the calculator.
 *  Note that there is just one set of register objects
 * @author Gary T. Leavens
 */
public class Registers {
    /** The number of the registers we have. */
    public final static int NUM_REGS = 10;
    /** The storage for each of the registers. */
    private static double [] regs = new double[NUM_REGS];

    /** Return the value stored in the register with the given index.
     * @param index, the number of the register to fetch
     */
    //@ requires 0 <= index && index < NUM_REGS;
    public static /*@ pure @*/ double get(int index) {
        return regs[index];
    }
       
    /** Store the value in the register with the given index.
     * @param index, the number of the register to put the value in.
     * @param value, the value to store.
     */
    //@ requires 0 <= index && index < NUM_REGS;
    public static void put(int index, double value) {
        regs[index] = value;
    }
}