# Here class Employee has the code common to all employees,
# There are 3 subclasses that refine Employee with more
# details.

class Employee:
    Count = 0
    def __init__(self, name, jobTitle):
        self.name = name
        self.title = jobTitle
        Employee.Count = Employee.Count + 1
        self.employeeNumber = Employee.Count

    def __str__(self):
        return "Name: %s  Employee Number: %d  Title: %s" % (self.name, self.employeeNumber, self.title)

    def Pay(self, week):
        pass
    
class SalariedWorker(Employee):
    # Salaried workders are paid once a month (every 4th week)
    # Then they are paid one twelfth of their annual salary
    def __init__(self, name, jobTitle, annualSalary):
        Employee.__init__(self, name, jobTitle)
        self.salary = annualSalary

    def __str__(self):
        return "%s is a %s " %(self.name, self.title)

    def Pay(self, week):
        if week % 4 == 3:
            print("   Pay %s $%.2f" %(self.name, self.salary/12.0))
            
    
class HourlyWorker(Employee):
    # Hourly workers are paid every week.
    # Each period they are paid 40 times their hourly wage.
    def __init__(self, name, jobTitle, hourlyWage):
        Employee.__init__(self, name, jobTitle)
        self.wage = hourlyWage

    def __str__(self):
        return "%s is an hourly worker with wage $%d" % (self.name, self.wage)

    def Pay(self, week):
        print("   Pay %s $%.2f" % (self.name, self.wage*40) )

class Robot(Employee):
    # Robots aren't paid
    RobotCount = 0

    def __init__(self):
        self.name = "Robot%d" % Robot.RobotCount
        Robot.RobotCount = Robot.RobotCount + 1
        Employee.__init__(self, self.name, "Robot")

    def __str__(self):
        return "%s is a robot" % (self.name)
        
def Hire(list, employee):
    list.append(employee)

def PayWorkers(list, numPeriods):
    for week in range(0, numPeriods):
        print( "Pay period %d" % week )
        for employee in list:
            employee.Pay(week)

def main():
    Staff = []

    Hire( Staff, SalariedWorker("Suzie", "Engineer", 50000) )
    Hire( Staff, SalariedWorker( "Bob", "Boss", 120000) )
    Hire( Staff, HourlyWorker( "Fred", "Construction Worker", 10))
    Hire( Staff, HourlyWorker( "Hermione", "Witch", 50) )
    Hire( Staff, Robot() )
    Hire( Staff, Robot() )

    for x in Staff:
        print( x )

    PayWorkers( Staff, 12) 

    print( "We have %d employees." %Employee.Count )

          
        
main()
            
