-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlecture_6.py
More file actions
46 lines (34 loc) · 1.09 KB
/
lecture_6.py
File metadata and controls
46 lines (34 loc) · 1.09 KB
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
41
42
43
44
45
46
# static methods
class Employee:
num_of_employee = 0
raise_amount = 1.04
def __init__(self,first,last,pay):
self.first = first
self.last = last
self.pay = pay
self.email = first +'.'+last + '@company.com'
Employee.num_of_employee += 1
def fullname(self):
return '{} {}'.format(self.first,self.last)
def apply_raise(self):
self.pay = int(self.pay * self.raise_amount)
# self.pay = int(self.pay * Employee.raise_amount)
@classmethod
def set_raise(cls,amount):
cls.raise_amount = amount
@classmethod
def from_string(cls, emp_str):
first,last,pay = emp_str.split('-')
return cls(first,last,pay)
@staticmethod
def is_workday(day):
if day.weekday() == 5 or day.weekday() == 6:
return False
return True
emp1 = Employee('Ashwini','Samal',70000)
emp2 = Employee('Dakshina','Thapa',100000)
import datetime
my_date = datetime.date(2024, 6, 7)
print(Employee.is_workday(my_date))
my_date = datetime.date(2024, 6, 8)
print(Employee.is_workday(my_date))