A company has different types of employees and requires to manage the calculation of their salaries based
on different parameters. Figure 1 illustrates the different types of employees of this company which are the
following types: Employee, Permanent Employee, Temporary Employee, Consultant, Manager and
Consultant Manager. Employee
Permanent_Employee Manager Temporary_Employee
● bonus ● benefits ● hours
● cal_salary() ● cal_salary()
Figure 1: Class Diagram of Employees
• Employee has the following properties: name, id and salary.
• Permanent Employee is a Employee. A Permanent Employee has benefits that he/she can select from [”health insurance”], [”retirement”], or both [”retirement”, ”health insurance”]. Implement a method cal salary() to calculate the actual salary based on selected benefits. If benefits =
[”health insurance”] then return salary ∗ 0.9, if [”retirement”] then salary ∗ 0.8 and if benefits =
[”retirement”, ”health insurance”] is selected then salary ∗ 0.7.
• Temporary Employee has a property ”hours” which is the working hours per mount. The salary
property represents the amount that a temporary employee is paid per hour. Implement a method
cal salary() to calculate the actual salary by returning salary ∗ hours
• Consultant a Consultant is a Temporary Employee and has in addition to travel. The property
travel represents number of travel trips that a Consultant has to do and is paid additionally 1000
dollar for each travel. Implement a method cal salary() to calculate the actual salary similar to a
Temporary Employee with an additional payment of travel ∗ 1000. (Tip: Try to reuse your code as
much as possible to avoid having duplicated code)
• Manager A manager is a special type of employee and is paid with a bonus payment in addition
to his/her main salary. Manager has a property bonus which adds to his/her main salary on top.
Implement a method cal salary() to return salary + bonus
• Consultant Manager is a Consultant and is a Manager as well. A Consultant Manager has travel,
hours of work and bonus payment. Implement a method cal salary() to calculate the salary similar to
a Temporary Employee and Consultant with an additional bonus payment. The cal salary() method
should return salary ∗ hours + travel ∗ 1000 + bonus
Also, please consider the following implementation instructions for this assignment:
• Each of your class constructors should use the following format ” init (self, **kwargs)”
• Each of your classes should have a string method implementation (Define str (self) in each of your
classes). You can design a string method to represent the objects in a string format. (print outs are not
important for tests on Gradescope)
• You can find a template for your implementation in file employee.py. You do not need to change the
main function. In main() function we will illustrate the various functions that you have written for the
classes but it is not used to test your implementation.
• The file (employee.py) that you will be submitting should follow the standard coding conventions in
as good as possible. (We will not reduce points because of any violations)
• Write for each of your classes and methods a short text documentation.
1PEP 8 Style Guide for Python Code https://www.python.org/dev/peps/pep-0008/
How to run the template?
Mac: python3 employee.py
Windows: python employee.py
No input data is needed. Examples are implemented in main() function.
The example output will be:
2 C h ri s , UT1 , None
4 P e rm a n e nt Em pl o y e e
5 Emma, UT2 , 1 0 0 0 0 0 , [ ’ h e a l t h i n s u r a n c e ’ ]
7 Tem p o ra r y Em pl o yee
8 Sam , UT3, 1 0 0 , 4 0
10 C o n s u l t a n t
11 John , UT4, 1 0 0 , 4 0 , 1 0
14 C h a r l o t t e , UT5, 1 0 0 0 0 0 0 , 1 0 0 0 0 0
16 C o n s ult a nt M a n a g e r
17 Matt , UT6 , 1 0 0 0 , 4 0 , 4 , C o n s ult a nt M a n a g e r
18 Matt , UT6, 1 0 0 0 , 1 0 0 0 0
20 Check S a l a r i e s
21 Emma ’ s S a l a r y i s : 9 0 0 0 0. 0
23 Emma ’ s S a l a r y i s : 9 0 0 0 0. 0
25 Emma ’ s S a l a r y i s : 7 0 0 0 0. 0
27 Sam ’s S a l a r y i s : 4 0 0 0. 0
29 J o h n ’s S a l a r y i s : 1 4 0 0 0. 0
31 C h a r l o t t e ’ s S a l a r y i s : 1 1 0 0 0 0 0. 0
33 Matt ’s S a l a r y i s : 5 4 0 0 0. 0
You may not change the names of the functions listed. They must have the functionality as given in the
specifications. You can always add more functions than those listed.
For this assignment you may work with a partner. Both of you must read the paper on Pair Programming2
and abide by the ground rules as stated in that paper. If you are working with a partner then only one of you
will be submitting the code. But make sure that your partner’s name and UT EID is in the header. If you are
2Read this paper about Pair Programming https://collaboration.csc.ncsu.edu/laurie/Papers/
working alone then remove the partner’s name and eid from the header.
Turn in your assignment on time on Gradescope system on Canvas. For the due date of the assignments,
please see the Gradescope and Canvas systems.
1.2 Academic Misconduct Regarding Programming
In a programming class like our class, there is sometimes a very fine line between ”cheating” and acceptable
and beneficial interaction between students (In different assignment groups). Thus, it is very important that
you fully understand what is and what is not allowed in terms of collaboration with your classmates. We
want to be 100% precise, so that there can be no confusion.
The rule on collaboration and communication with your classmates is very simple: you cannot transmit
or receive code from or to anyone in the class in any way – visually (by showing someone your code),
electronically (by emailing, posting, or otherwise sending someone your code), verbally (by reading code to
someone) or in any other way we have not yet imagined. Any other collaboration is acceptable.
The rule on collaboration and communication with people who are not your classmates (or your TAs or
instructor) is also very simple: it is not allowed in any way, period. This disallows (for example) posting
any questions of any nature to programming forums such as StackOverflow. As far as going to the web and
using Google, we will apply the ”two line rule”. Go to any web page you like and do any search that you
like. But you cannot take more than two lines of code from an external resource and actually include it in
your assignment in any form. Note that changing variable names or otherwise transforming or obfuscating
code you found on the web does not render the ”two line rule” inapplicable. It is still a violation to obtain
more than two lines of code from an external resource and turn it in, whatever you do to those two lines after
you first obtain them.
Furthermore, you should cite your sources. Add a comment to your code that includes the URL(s) that
you consulted when constructing your solution. This turns out to be very helpful when you’re looking at
something you wrote a while ago and you need to remind yourself what you were thinking.
We will use the following Code plagiarism Detection Software to automatically detect plagiarism.
• Staford MOSS
• Jplag – Detecting Software Plagiarism
https://github.com/jplag/jplag and https://jplag.ipd.kit.edu/