package rebelsky.pal; /** * The PAL instruction to write a constant string. * * @author Samuel A. Rebelsky * @version 1.0 of November 2002. */ public class SWrite implements Instruction { // +--------+------------------------------------------------------------ // | Fields | // +--------+ /** The string to write. */ String str; // +--------------+------------------------------------------------------ // | Constructors | // +--------------+ /** * Create a new instruction to write a string. */ public SWrite(String str) { this.str = str; } // SWrite(String) // +---------+----------------------------------------------------------- // | 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(str); hal.out.flush(); } // execute(Computer) /** Convert the instruction to a string (usually for printing). */ public String toString() { return " SWRITE '" + str + "'"; } // toString() } // class SWrite