Fun with Streams
Part 1
Make a WordStream class that takes a stream of characters and produces a
stream of words. A word is a string with no white space or punctuation.
aStream := WordStream on: 'resume.tex' asFilename readstream.
aStream next
will return the first word in the file 'resume.tex'.
Use the testing framework to write a test suite for WordStream.
Make sure that 'hello world' has two elements on it, as does
'hello world ', ' hello world' and 'hello world'. You
should write other tests as well, but those are often missed.
Part 2
Use WordStream to write a script that counts the words in a document (use a
bag) and prints out a report that tells you the number of times each word
appeared in the document.
The report should sort the words, most popular first. Make the script be a
class method of WordStream.
Part 3
Use WordStream to write a script that finds all dollar words in a document.
A dollar word is a word that is worth 100 points. The points in a word is
the sum of the points of its letters, and 'a' is worth 1 point, 'b' is
worth 2 points, etc. This was a homework in my daughter's second grade class.
She spent a week on it. Too bad she didn't know how to program!
Find a large text file (like the HTML source for this page) and
process it to find the dollar words. You'll have to make a stream
on the file, use it as input to your WordStream, and then select the
dollar words.
Part 4
Change the payroll example so that you can save all the data using BOSS,
and restore it, as well. If you save the PayrollSystem then it should
save all the Employees, which will save all the EmployeeTransactions.
So, concentrate on the object that contains all the other objects, i.e.
the PayrollSystem.