1) The payroll system only withholds taxes. Change it so that it can withhold insurance payments, too. You'll have to change the Paycheck class so that it records how much was withheld for insurance and can print it on a paycheck. You'll have to add a new instance variable to Employee to keep the total insurance payments withheld, and hack Employee>>makePaycheckAt: to compute the amount withheld so that it can be stored in the paycheck. Note that makePaycheckAt: does NOT change the Employee class. You don't update the totals in Employee when you create a Paycheck, but when you post it. Not everyone will have the same insurance payments. However, you can assume that each person has a fixed amount withdrawn from each paycheck. Make a transaction for changing this amount.
2) Change the payroll system so that it withholds payments to a retirement account.
Wait! Isn't this just like the last problem? What if tomorrow you are asked to withhold donations to the United Way, and the day after that you are asked to withhold child support payments?
It is common for an employer to withhold more than just taxes. The current design of the payroll system does not make it very easy to add a new kind of withholding. Moreover, it is unlikely that everybody would want to have the same withholdings. There needs to be a way to add a new withholding easily that also makes it easy for every employee to have a different set of withholdings.
The standard trick to keep from having to add new instance variables is to use a dictionary. An Employee would have an instance variable "withholdings" that was a dictionary that mapped strings (or, better yet, symbols) to numbers. If you wanted taxes you would say (withholdings at: #taxes). The paycheck probably needs to have a dictionary that listed the withholdings, too.
There has to be some code to compute the withholdings for each paycheck. Different withholdings require different algorithms. The best way to let each Employee have a different set of algorithms is to make the algorithms into objects. There should be a Withholder class hierarchy. Each Withholder is able to take an employee and a paycheck, compute the amount to be withheld, and add it to the paycheck. Withholders will get used during makePaycheckFor:. Basically, makePaycheckFor: will just create the initial paycheck, initialize it with the date, employee and original amount, and then will pass the paycheck off to the EmployeeUs Withholders to have them compute the withholdings.
Step 1: Create a Withholder class and one subclass, TaxWithholder. A TaxWithholder takes a TaxRule, so there is no reason for the Employee to have a TaxRule. Instead, it will have a collection of Withholders. For the time being, it will have one for taxes and one for insurance. Change makePaycheckFor: to use the Withholders to compute the withholding. Make sure it does what it does now.
Step 2: Change Employee and Paycheck to use a dictionary to store the various kinds of withholdings. First change one, and test it, then change the other. Make sure it does what it does now before you go adding new kinds of withholdings. You'll have to change both postTo: in Paycheck and makePaycheckAt: in Employee.
Step 3: Add new kinds of withholdings. Be creative!