class Employee: 'to represent a generic employee' def __init__(self, FirstName, LastName, ID): self.__FirstName = FirstName self.__LastName = LastName self.__ID = ID def setFirstName(self, FirstName): if(FirstName.isalpha()): self.__FirstName = FirstName else: print("Wrong Input") def getFirstName(self): return self.__FirstName def setLastName(self, LastName): if (LastName.isalpha()): self.__LastName = LastName else: print("Wrong Input!") def getLasstName(self): return self.LastName def setID(self, ID): if(ID.isdigit()): self.__ID = ID else: print("Wrong Input!") def getID(self): return self.__ID def printInfo(self): print("First Name: ", self.__FirstName, "\nLast Name: ", self.__LastName, "\nID: ", self.__ID) def earnings(self): raise NotImplementedError("Subclass must implement abstract method") class FullTimeEmployee(Employee): 'has a fixed monthly salary regardless of the number of hours worked' def __init__(self, FirstName, LastName, ID, monthlySalary): Employee.__init__(self, FirstName, LastName, ID) self.__monthlySalary = monthlySalary def setmonthlySalary(self, monthlySalary): if(monthlySalary > 500 and monthlySalary < 10000): self.__monthlySalary = monthlySalary else: print("Wrong Input!") def getmonthlySalary(self): return self.__monthlySalary def earnings(self): return self.__monthlySalary def printInfo(self): print("Employee Type: Full Time") Employee.printInfo(self) class PartTimeEmployee(Employee): 'Employee who is paid by the hour' def __init__(self, FirstName, LastName, ID, hourlyWage, Hours): Employee.__init__(self, FirstName, LastName, ID) self.__hourlyWage = hourlyWage self.__Hours = Hours def sethourlyWage(self, hourlyWage): if(hourlyWage > 2 and hourlyWage < 20): self.__hourlyWage = hourlyWage else: print("Wrong Input!") def gethourlyWage(self): return self.__hourlyWage def setHours(self, Hours): if(Hours > 0 and Hours < 150): self.__Hours = Hours else: print("Wrong Input!") def getHours(self): return self.__Hours def earnings(self): return self.__hourlyWage * self.__Hours def printInfo(self): print("Employee Type: Part Time") Employee.printInfo(self) ######################################################### # Driver x = FullTimeEmployee("Anas", "Barakat", 1180050,1000) print(x.earnings()) z = PartTimeEmployee("Mohanad", "Hussin", 1181401,5,5) print(z.earnings()) y = Employee("Tareq", "Shannak", 1181404) print(y.earnings())