![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
MP2Homework 2Part 1. Payroll exampleExercise 1. Get the source code for the Payroll example that we did in class, downloading the file CS598rej-Payroll HW2.st You can upload the source code to your image by invoking 'open...' from the World Menu, then choose 'file list', then browse to the place where you downloaded CS598rej-Payroll HW2.st Select the file in the top right pane, then invoke the context menu (right clicking). Choose 'fileIn entire file'. You should be able to see a class category called 'CS598rej-Payroll HW2' in your class browser. 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. For your convenience we provided some automated tests that you can download and fileIn by following the same procedure as before. The tests are at CS598rej-Grading_HW2.st You can invoke the SUnit test runner from World Menu 'open...' , then choose 'SUnit Test Runner'. Initially all the test classes in your image are selected. Deselect all and pick only GraderHW2. Run it - you should see it turns red since you have to implement some code first. After you implemented all the missing code, all but one test (testPayrollSystemWithJohn) should pass. The next exercise will guide you in making the last test pass too.Exercise 2. Test the Payroll system. There are three test case classes already: You need to add one method (call it 'testTakeHomePay') to PayrollSystemTestCase to test the methods in
PayrollSystem, Employee and Paycheck related to making paychecks and checking that each employee is payed what's expected. In the 'testTakeHomePay' method create a fixture for the following case: Part 2. Use of inheritanceExercise 2.1. Suppose the following class definitions and methods:
Evaluate the following expressions and explain the results: a) b) c) d)
e) Given the following assignments: explain what happens with each of the following expresions:
AdviceLook at the test methods to see what they are checking for (and how they check it). The test cases illustrate the reflective nature of the Smalltalk language. Test cases also serve as a "poor man's" form of documentation. They show you a concrete example of how to create new objects and how to perform operations on them. DeliverablesThe easiest way for Part 1 is to send me the text that shows all the methods that you have added/modified. This is better than a fileOut of the entire class since that contains everything even the things that have not changed. That makes it hard for me to actually see the changs. Use the standard notation to describe the changed methods. For instance methods: ClassName >> myMethodWith: param1 and: param2 "Do something here" ^ param1 + param2 For class methods: ClassName class >>myMethodWith: param1 and: param2 "Do something here" ^ param1 + param2 Any reorganization (creating new categories, renaming existing ones) should also be stated. For Part 2 just explain the result of each evaluation. You do not need to send me the code even if you implemented those classes to test it out. Link to this Page
|