# Arup Guha
# 6/10/2024
# Example to illustrate inheritance

class employee:

    firstName = ""
    lastName = ""
    id = 0
    payPerHour = 10.00
    totalPay = 0

    # Standard constructor.
    def __init__(self,fName,lName,myid,payPH):
        self.firstName = fName
        self.lastName = lName
        self.id = myid
        self.payPerHour = payPH
        self.totalPay = 0

    # We'll just print name and total pay here.
    def __str__(self):
        return self.lastName+", "+self.firstName+" Total Pay = "+str(self.totalPay)

    # To keep it simple, no overtime!
    def pay(self,hours):
        self.totalPay += hours*self.payPerHour

    # This is for a straight one time bonus of add dollars.
    def bonus(self,add):
        self.totalPay += add

class commissionemployee(employee):

    numSold = 0
    bonusPerItem = 0

    # Here we just also assign the last couple new instance variables after
    # calling super.
    def __init__(self,fName,lName,myid,payPH,payPI):
        super().__init__(fName,lName,myid,payPH)
        self.numSold = 0
        self.bonusPerItem = payPI

    # We use super to give our new string representation.
    def __str__(self):
        return super().__str__()+" Items Sold = "+str(self.numSold)

    # Here we get pay for both our hours and commission.
    def payF(self,hours,newitems):
        super().pay(hours)
        self.numSold += newitems
        self.totalPay += newitems*self.bonusPerItem

    
# Basic test of employee
def main():

    # Set up employees.
    aleena = employee("Aleena", "Patel", 2233447, 12)
    geno = employee("Geno", "Lin", 8675432, 11)
    workers = []
    workers.append(aleena)
    workers.append(geno)

    # Pay them.
    print("First time pay Aleena, Geno.")
    workers[0].pay(20)
    workers[1].pay(10)
    for w in workers:
        print(w)
    print()

    # Now add a bonus.
    print("Now give the two of them bonuses.")
    for w in workers:
        w.bonus(50)
    for w in workers:
        print(w)
    print()

    # Now let's test one commission employee.
    print("Just test our new commisionemployee Jahmal.")
    workers.append(commissionemployee("Jahmal","Moss",3434345,20,80))
    workers[2].pay(10,3)
    print(workers[2])
    print()

    # Add another bonus to all.
    print("One final bonus to all.")
    for w in workers:
        w.bonus(100)
    for w in workers:
        print(w) 

# Run it!
main()
