package rebelsky.pal; /** * The PAL instruction to read an integer. * * @author Samuel A. Rebelsky * @version 1.1 of December 2002. */ public class FRead implements Instruction { // +--------+------------------------------------------------------------ // | Fields | // +--------+ /** The container to read. */ Variable location; // +--------------+------------------------------------------------------ // | Constructors | // +--------------+ /** * Create a new instruction to read a location. */ public FRead(Variable location) { this.location = location; } // IWrite(Variable) // +---------+----------------------------------------------------------- // | Methods | // +---------+ /** * Execute the instruction on a machine. * * @exception Exception * If the memory location is invalid. */ public void execute(Computer hal) throws Exception { // hal.out.print("Enter a real number: "); // hal.out.flush(); location.fset(hal, Float.parseFloat(hal.in.readLine())); } // execute(Computer) /** Convert the instruction to a string (usually for printing). */ public String toString() { return " FREAD " + location.toString(); } // toString() } // class FRead