0% found this document useful (0 votes)
15 views

MyWriter Cs

Uploaded by

Slime UNICORN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

MyWriter Cs

Uploaded by

Slime UNICORN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 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