@Kapil3sh/

Inheritance and Creating Subclasses

Python

No description

fork
loading
Files
  • main.py
main.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
class Employee:
  raise_amt = 1.04
  num_of_employees = 0

  def __init__(self, first, last, pay):
    self.first = first
    self.last = last
    self.pay = pay
    self.email = first+"."+last+"companyname.com"
    Employee.num_of_employees += 1

  def display_full(self):
    return '{} {}'.format(self.first,self.last)
  
  def apply_raise(self):
    self.pay = int(self.pay*self.raise_amt)
    return self.pay
    
print(Employee.num_of_employees)

emp1 = Employee('kapilesh','kothavale',60000)
emp2 = Employee('test','user',50000)

print(Employee.num_of_employees)

print(emp1.pay)
emp1.apply_raise()
print(emp1.pay)

emp1.raise_amt = 1.05