You are on page 1of 1

using System;

using System.IO;

class MyWriter : StreamWriter


{
// constructor for MyWriter object
public MyWriter( string fileName )
: base( fileName )
{
} // end constructor

// write integer to file


public void WriteInteger( int output )
{
// pad the integer with zeros
string toWrite = output.ToString().PadLeft( 10, '0' );

Write( toWrite ); // write to file


} // end method WriteInteger

// write boolean to file


public void WriteBoolean( bool output )
{
// a written boolean is 5 characters long
if ( output )
Write( "true " );
else
Write( "false" );
} // end method WriteBoolean

// write string to file


public void WriteString( string output )
{
// each string ends with "ENDOFSTRING"
Write( output + "ENDOFSTRING" );
} // end method WriteString
} // end class MyWriter

You might also like