Search

Classes and Objects

Class:

class  Employees:
	def __init__(self, name, department, role, salary, yearsEmployed):
		self.name = name
		self.department = department
		self.role = role
		self.salary = salary
		self.yearsEmployed = yearsEmployed
		
	def eligible_for_retirement(self):
		if self.yearsEmployed >= 20:
			return True
		else:
			return False

Code to run it:

#!/bin/python3

from Employees import Employees

e1 = Employees("Bob", "Sales", "Director of Sales", 100000, 20)
e2 = Employees("Linda", "Executive", "CIO", 150000, 10)

print(e1.name)
print(e2.role)
print(e1.eligible_for_retirement())