A06
A06
class Employee:
def __init__(self, emp_id, name ,salary,department):
self.emp_id=emp_id
self.name = name
self.__salary=salary
self.department = department
def display_details(self):
print(f"Employee ID :{self.emp_id}")
print(f"Name :{self.name}")
print(f"Salary :${self.__salary}")
print(f"Department :{self.department}")
def get_salary(self):
return self.__salary
def set_salary(self,new_salary):
if new_salary >=0:
self.__salary =new_salary
print(f"Salary updated to ${self.__salary}")
else:
print("Invalid Salary")
def give_bonus(self,amount):
if amount>0:
self.__salary += amount
print(f"Bonus of ${amount} added.New salary is ${self.__salary}")
else:
print("Bonus must be positive!")
def update_department(self,new_department):
self.department = new_department
print(f"Department changed to :{self.department}")
emp1 = Employee(101,"ABC",5000,"IT")
"""
Output:-
cc76@cc76:~$ python3 h00.py
===Initial Employee Details===
Employee ID :101
Name :ABC
Salary :$5000
Department :IT
"""