EEN218 Third Homeword, due Tuesday 7th March 2000
In class last week, we developed a new object called input
to encapsulate the various operations required for reading data
from keyboard or files in various forms. The homework is to define
the obvious counterpart to this for writing output to the screen or
a file. If you need to be reminded of the input class
here it is.
The class you define should be called "output", and should have two
constructors: the default should create an output object for sending
output to your terminal/screen; the other constructor should take
a string parameter and create a file (with that name) for the output
to go to.
You must provide buffering. That is, output should not be sent to
your terminal or file as soon as you produce it. Your functions should
add the output characters to a buffer (a long string) just like the
one the input class read from. The buffer should only really be written when:
It gets full, or a newline '\n' is sent, or the file is closed, or the
user explicitly requests it. Buffering input and output has huge
benefits for the efficiency of a whole computer system.
You should add whatever functions you consider important. They should
provide at least the ability to output a single character, a string,
and an int. Is there any point in having an unwritechar() function
like the unreadchar() in the input class?
Electronic submissions only, as hw3, on or before Tuesday 7th March.