-
Notifications
You must be signed in to change notification settings - Fork 6
/
Classes_objects.py
35 lines (23 loc) · 926 Bytes
/
Classes_objects.py
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
#Classes and Objects Employee details
class Employee:
incr = 1.05
no_of_emps = 0
def __init__(self, first, last, pay):
self.fname = first
self.lname = last
self.pay = pay
self.email = first + '' + last + '@company.com'
Employee.no_of_emps += 1
def display_details(self):
print('First Name: {}\nLast Name: {}\nPay: {}\nEmail: {}'.format(self.fname, self.lname, self.pay, self.email))
print('==================================================')
def apply_incr(self):
self.pay = int(self.pay * self.incr)
#Creating Objects
emp1 = Employee('Ram','babu',50000)
emp2 = Employee('Jack','jones',14200)
emp3 = Employee('Tim', 'Cook', 58000)
emp1.display_details() #this and also the below one does the same
Employee.display_details(emp2)
#printing the employee data
#print(Employee.no_of_emps)