Facebook
From Sweet Porcupine, 5 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 49
  1. from Employee import Employee
  2. class Developer (Employee):
  3.     def __init__(self,name,pay,prog_lang):
  4.         self._prog_lang = prog_lang
  5.         super().__init__(name,pay)
  6.    
  7.     def apply_pay_rise(self):
  8.         super().apply_pay_rise()
  9.         self._pay = self.pay + 5000
  10.        
  11.        
  12.        
  13. class Employee:
  14.     pay_rise = 1.1
  15.     def __init__(self,name,pay):
  16.         self._name = name
  17.         self._email = self._name + ".@gmail.com"
  18.         self._pay = pay
  19.    
  20.     def apply_pay_rise(self):
  21.         self._pay = int(self._pay) * self.pay_rise
  22.         return self._pay
  23.    
  24.     @property
  25.     def pay(self):
  26.         return self._pay      
  27.        
  28.        
  29. from Employee import Employee
  30. from Developer import Developer
  31.  
  32. print("Creating an Employee Object")
  33. input_str = input("Enter Employee details in comma separated format\n")
  34. name, pay = input_str.split(",")
  35. employee = Employee(name, pay)
  36.  
  37. print("\nCreating a Developer Object")
  38. input_str = input("Enter Developer details in comma separated format\n")
  39. name, pay, prog_lang = input_str.split(",")
  40. developer = Developer(name, pay, prog_lang)
  41.  
  42. print("Employee Old Pay : ", employee.pay)
  43. employee.apply_pay_rise()
  44. print("Employee New Pay : ", employee.pay)
  45.  
  46. print("Developer Old Pay : ", developer.pay)
  47. developer.apply_pay_rise()
  48. print("Developer New Pay : ", developer.pay)
  49.  
  50.  
  51.  
  52.  
  53.  
  54.