Skip to content

Commit 16e236d

Browse files
Add files via upload
1 parent 7b5d8ac commit 16e236d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Sample_Inheritence.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# and try to analyze the inheritence behaviour of the sub-class.
33

44
import datetime
5-
5+
#------------------------------------------------------------------------- PARENT CLASS EMPLOYEE -------------------------------------------------------------------
66
class Employee(object):
77

88
raise_amount = 1.15
@@ -26,9 +26,10 @@ def set_raise_amount(cls,amount):
2626
amount : amount """
2727

2828
cls.raise_amount = amount
29-
29+
30+
3031
def apply_raise(self):
31-
self.pay = self.pay*self.raise_amount # Every class variable is accessed using the class name
32+
self.pay = self.pay*Employee.raise_amount # Every class variable is accessed using the class name
3233
return self.pay
3334

3435
@classmethod
@@ -42,6 +43,8 @@ def is_weekday(day):
4243
if day.weekday() == 5 or day.weekday() == 6:
4344
return False
4445
return True
46+
47+
#------------------------------------------------------------------ Child Class Developer --------------------------------------------------------------------------
4548

4649
class Developer(Employee):
4750

@@ -62,7 +65,7 @@ def from_string(cls,developer_string):
6265
first,last,pay,language = developer_string.split("-")
6366
return cls(first,last,int(pay),language)
6467

65-
68+
#-----------------------------------------------------------------
6669

6770

6871
def main():
@@ -104,6 +107,9 @@ def main():
104107
print()
105108
print("Invoking the inherited static method \"is_weekday\" using child class instance")
106109
print(Developer.is_weekday(datetime.date.today()))
110+
print("************************************************")
111+
print()
112+
107113
print(".-"*55)
108114
print("*"*100)
109115

0 commit comments

Comments
 (0)