The purpose of the homeworks is to prepare you for the class project. It also forces you to keep up with the course, and it lets me assume that you've read the book, so I won't have to lecture on the material. This is a graduate course, after all, so I assume that you'll learn the material from the book on your own, and I can concentrate on the material that isn't in the book, and making sure you see the big picture.
Homeworks will come fast and furious at first, then you'll move on to work in a project. Feel free to talk with other people about the homeworks. However, there will be tests and quizes based on the material in the homeworks, so if you don't do the work, you will do poorly. In fact, it is good to do your homework with a partner. You learn more with a partner, and you might spend less time. If you do a homework with someone else, just submit one solution and put both your names on it. Make sure that you are doing equal amounts of work. If your partner is doing most of the work, get another partner or you won't learn as much.
Send in all homeworks to cs497@chip.cs.uiuc.edu by 10:30 a.m. of the day it is due. Do NOT use attachments. Include all code by pasting it into your message. If you use attachments then we will end up with hundreds of little files, mostly with the same name. This makes it hard to tell which file is yours. Make the subject of your message by "homework 1", "homework 2", and so on. This will help us keep them separate if you are ahead of schedule. You can go as fast as you want, but we probably will hand back your homeworks along with everybody else's.
Many students have asked questions about the homeworks and have had them answered on the swiki. Take a look at these questions before you start a homework, and feel free to ask more questions. The homeworks change a little each semester, and we try to edit the questions to keep up with the changes, but sometimes we make mistakes.
Also, go to the class wiki and make an entry for yourself under the "list of people". Introduce yourself, explain why you want to take this class, and leave your e-mail address.
Pay close attention to the hint of 7.9. The problem is that some methods don't return what you expect. In particular, "x at: 3 put: 'third'" will not return x. However, "x at: 3 put: 'third'; yourself" will return x.
Do the exercises in chapter 8, sending us the results of 8.3 and 8.4. 8.5 is optional. Do the exercises in chapter 9 too, but don't send us anything.
Get the source code for the Payroll example that we did in class. Check the Employee class and the three subclasses of EmployeeTransaction to see whether they are using the proper pattern for initializing objects. In other words, whether there is a "complete creation method" as a class method and an "instance initialization method" as an instance method. If not, fix them, and report what you changed.
Write a script that simulates the following. Write it in a workspace.Sept 3 adding to it little by little. Read the code to figure out the exact syntax for anything you don't know how to do. Note that the class method "test" of PayrollSystem is a lot like this. Send in the script for the following:
John Doe was hired May 1, 1999. His initial salary was $20 an hour. He turned in his time-card on May 5 and had worked 40 hours. He worked 40 hours the week of May 12, too. He received a pay-check on May 15. What was his take-home pay?
The payroll system doesn't handle vacation. Class Employee has a variable defined for it, and each time-card collects the amount of vacation time that was taken that week, but the code for processing time-cards doesn't do anything about vacation.
Change the payroll system to record the amount of vacation time that has been taken and the vacation time that has accrued. Assume that for every 50 hours of non-overtime that an employee works, they get 2 hours of vacation time. You should not need to add any more instance variables to any classes. You could do this by adding to accrued vacation (hours worked / 25) - hours of vacation taken. Note that this will lead to fractional hours of vacation accumulated. This might be a problem if this were being written in COBOL, but it is OK for Smalltalk.
To find where the work gets done, try single-stepping through the posting of a time-card. Place a halt to start the debugger, and then single-step from there. You'll have to figure out how to get the hours of vacation taken and the hours worked. They are stored in the time-card.
You will have to change the initialization method to initialize the Employee properly. Then you'll have to change everyplace you read the variable to use #at:, everyplace you assign to the variable to use #starting:become:, and everyplace you increment the variable to use #at:add:.
Define a method for Employee called salaryHistoryOn: aStream. It prints a report on aStream that gives the dates of all salary changes and what the new salary was. The report should look something like
January 15, 1975: $2.00 July 15, 1975: $2.10 January 15, 1976: $2.30 July 15, 1976: $2.50Do NOT hand in the entire payroll example. Just hand in your changes. We do not want to run your program, we want it to be so clear that we can read the changes and tell that it is correct.
Some people are planning to use a different version of Smalltalk for their final project, such as VA or Squeak. They shouldn't bother to learn the VisualWorks GUI or to do the final homework. Instead, they might try to port the payroll system to their target system and to write a GUI for it. This will probably take a week or two, but will be good preparation for the project.