-
Notifications
You must be signed in to change notification settings - Fork 0
/
python_raise_calculator
41 lines (24 loc) · 1.08 KB
/
python_raise_calculator
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""Inheritance allows us to define a class that inherits all the methods and properties from another class.
Parent class is the class being inherited from, also called base class.
Child class is the class that inherits from another class, also called derived class.
reduces code redundancy """
#system that has managers and developers as employees
class employee:
raise_new = 1.04 #raise is a reserved keyword in python
def __init__(default,firstname,lastname,pay):
default.firstname = firstname
default.lastname = lastname
default.pay = pay
default.fullname = firstname + " " + lastname
#method to print full name
def printfullname(default):
return "{} {}" .format(default.firstname, default.lastname)
def apply_raise(default):
default.pay = int(default.raise_new * default.pay)
class developer(employee):
raise_new = 1.10
employee1 = developer("caleb","Mayaka", 380000)
print(employee1.fullname)
print(employee1.pay)
employee1.apply_raise()
print(employee1.pay)