![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
MP7Fun with StreamsAt the bottom of this page, you will find the parcel with the test cases for this homework as well as two test files: ‘resume.txt’ and ‘bag.txt.’ File in the parcel and save the files in the top level Squeak directory. If you run into problems opening files, save the image and restart it.When a file is not closed properly, it may fail to open next time, because the system stores all file handles. Restarting the image solves this problem. Part 11.1 Implement a WordStream class that takes a string and produces a stream of words. A word is a string with no white space or punctuation. Test case testWordStream tests this class for input file ‘resume.txt.’ 1.2 Use the testing framework to write a test suite for WordStream. One such test is to count the number of words in a file. Make sure that 'hello world' has two elements on it, as does 'hello world ', ' hello world' and 'hello world' (two spaces between). You should write other tests as well, but those cases are often missed. Part 22.1 Use WordStream to write a script (named countWordsIn:) that counts the words in a document (use a bag) and produces a list of words with the number of times each word appeared in the document. It should sort the words, most popular first. Make the script be a class method of WordStream. Use test case testBag as a starting point. 2.2 Add other test cases to verify your code. Part 3Use WordStream to write a script that finds all dollar words in a document. Call it findDollarWords:. A dollar word is a word that is worth 100 points. The number of 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! Test case testDollarWords assumes that the input file is the text version of this HTML page. Save it as ‘bigfile.txt’ and run the test. You may consider writing simpler tests first. Part 4Change the Payroll example so that you can save all the data persistently 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. Place the code for this in a separate class in the HW7-Grading parcel. Call this class PersistentPayrollSystem. How does persistence work in Squeak? Browse class ReferenceStream to see. FilesMain files for testing: bag.txt resume.txt Some other files that you can use for testing: manycopies.txt punctuation.txt wierdspacing.txt CS598rej-Grading HW7.st DeliverablesfileOut the parcel CS598rej-Grading HW7 and paste the text into an e-mail. For your own test cases, make sure that you write a short comment on what you are testing especially if you are testing some corner case and it is not immediately clear what it is that you are testing for. Link to this Page
|