package rebelsky.pal; /** * An integer constant for PAL. * * @author Samuel A. Rebelsky * @version 1.1 of December 2002 */ public class IConstant extends Variable { // +--------+------------------------------------------------------------ // | Fields | // +--------+ /** The value of the constant. */ int value; // +--------------+------------------------------------------------------ // | Constructors | // +--------------+ /** * Build a new integer constannt. */ public IConstant(int val) { this.value = val; } // IConstant() // +---------+----------------------------------------------------------- // | Methods | // +---------+ /** * Get the integer stored in this constant. */ public int iget(Computer hal) { return this.value; } // iget() /** * Fail to set the value of the constant. * * @exception Exception * Whenever this procedure is called (you can't change constants). */ public void iset(Computer hal, int newval) throws Exception { throw new Exception("Can't change the value of constants."); } // iset(int) /** Convert the location to a string (usually for printing). */ public String toString() { return "$" + this.value; } // toString() } // class IConstant