Assignment 2
Using and modifying classes
Submit before 11:30 Saturday January 27
Overview
For this assignment, you will continue your practice of using the Employee class and then modify it by adding and testing a new method.
Code writing and questions
This assignment uses the files from lab 2 (which now includes raises.txt and raises2.txt). Except where you are asked to modify the employee.py file, you are encouraged to place all of your code in a assn2.py file.
- (from lab 2) Write a function called give_select_raises. It should take a list of Employee objects as a parameter. Reading from raises.txt, it should give a raise (sometimes multiple times) to the object each time the employee id is presented in the file. This problem is not required for the lab, but will be required in the assignment.
- Modify the Employee class (in employee.py) with the following additions:
- Add a new instance variable called recommendation_count and initialize it to 0 in the __init__ method.
- Add a new method called recommend. Everytime is it called, it should increment the instance variable recommendation_count.
- Modify the give_raise method so that it does the following:
- Add an extra percent to the raise for each recommendation_count. For example, if the reccommendation_count is 2, the employee should receive a 4% (.04) raise.
- Reset the recommendation_count to 0.
- Write a python script (as a function or in a separate file) that tests your new, modified Employee class.
- Study the file raises2.txt. Note that it provides a series of actions for recommendations and give_raises. Write a function called process_raises. It should take a list of Employee objects created from emprecords.txt and apply recommend and give_raise actions indicated in raises2.txt.
- Test your process_raises function by running it and then using your display_employees function to show the results. You may compare your answer with others to check for correctness.
Deliverable
Create a text, word or pdf file that contains the following:
- A statement that summarizes your completion of the assignment. The statement should include any help you received or whether you discussed your assignment with others. Keep in mind that you may not copy code from others or allow others to copy your code.
- Your clearly labeled answers to explanations and questions
- A summary of the files included in the zip folder
- Demonstrations that show that your code works
Put your doc file and your py files (employee.py, assn2.py and txt files) in a folder, zip it, and submit it on D2L. Check that your submitted zip file is complete.
Grading
The assignment is worth 5 points. Full credit will be awarded to complete, accurate and well presented submissions. Points will be deducted for the following:
- Missing requirements
- Inaccuracies (possibly excepting minor ones)
- Poorly written explanations