Hi I am trying to write a method that prints a list of locations of the employees which report into a manager. The manager object is created and holds a list of ldaps (id’s) for the people who report to the manager.
How do I iterate through all employee objects – in this case 3 employees that have been created? The GetLocations method below only prints the managers location. Any help would be appreciated. Thanks!
I would like to have an output that says: Dublin, Dublin New York (formatting is irrelevant)
class Employee(object):
def __init__(self, ldap, name, location, salary, status):
self.ldap = ldap
self.name = name
self.location = location
self.salary = salary
self.status = status
class Manager(Employee):
def __init__(self, ldap, name, location, salary, status, reportees):
self.name = name
self.reportees = reportees
self.location = location
print 'Manager has been created.'
def GetLocations(self):
for location in [Employee]:
print Employee.location
employee1 = Employee('axlr', 'Axl Rose', 'Dublin', 50000, 'active')
employee2 = Employee('slash', 'Slash', 'Dublin', 50000, 'active')
employee3 = Employee('peterp', 'Peter Pan', 'New York', 50000, 'active')
manager1 = Manager('wayneg', 'Wayne Gretzky', 'Dublin', 50000, 'active', ['axlr', 'slash', 'peterp'])
I would add a static list of locations to the
Employeeclass: