5. Create a class BasePlusCommissionEmployee
a. BasePlusCommissionEmployee class is a child class of CommissionEmployee. It should inherit all the attributes of CommissionEmployee class and add its own attribute baseSalary.
b. Create a method called calculateTotalEarning which should inherit super class method calculateCommission and add baseSalary in it.
c. Create a method called displayData which should display the FirstName, LastName, Age, Address, ContactNumber, EmployeeID, OrganizationName, Position and totalEarning.
6 Create a complete class diagram of Question-01. Show relationship/inheritance between class.
(the #292598 is the first part and #292608 is the second part of this question and this is their part so I am requesting that to answers number 6 please also include part 1 and 2 of this question. thank you :)
class Person:
def __init__(self, FirstName, LastName, Age, Address, ContactNumber):
self.FirstName = FirstName
self.LastName = LastName
self.Age = Age
self.Address = Address
self.ContactNumber = ContactNumber
class Employee(Person):
def __init__(self, EmployeeID, OrganizationName, Position):
super().__init__()
self.EmployeeID = EmployeeID
self.OrganizationName = OrganizationName
self.Position = Position
class CommissionEmployee(Employee):
def __init__(self, commissionRate):
super().__init__()
self.commissionRate = commissionRate
def calculateCommission(self, GrossSale):
TotalEarning = GrossSale * self.commissionRate
return TotalEarning
def displayData(self):
print('First name: ', self.FirstName)
print('Last name: ', self.LastName)
print('Age: ', self.Age)
print('Address: ', self.Address)
print('Contact number: ', self.ContactNumber)
print('Employee ID: ', self.EmployeeID)
print('Organization name: ', self.OrganizationName)
print('Position: ', self.Position)
print('Commission rate: ', self.commissionRate)
print('Total earning: ', calculateCommission(self, GrossSale))
class SalariedEmployee(Employee):
def __init__(self, baseSalary):
super().__init__()
self.baseSalary = baseSalary
def CalculateNetSalary(self, ProvisionalTax=0.13, insurance=0.01,
FedTax=0.03):
NetSalary = self.baseSalary - self.baseSalary * ProvisionalTax - \
self.baseSalary * insurance - self.baseSalary * FedTax
return NetSalary
def displayData(self):
print('First name: ', self.FirstName)
print('Last name: ', self.LastName)
print('Age: ', self.Age)
print('Address: ', self.Address)
print('Contact number: ', self.ContactNumber)
print('Employee ID: ', self.EmployeeID)
print('Organization name: ', self.OrganizationName)
print('Position: ', self.Position)
print('Base salary: ', self.baseSalary)
print('Net salary: ',
CalculateNetSalary(self, ProvisionalTax=0.13, insurance=0.01,
FedTax=0.03))
class BasePlusCommissionEmployee(CommissionEmployee):
def __init__(self, baseSalary):
super().__init__()
self.baseSalary = baseSalary
def calculateTotalEarning(self, baseSalary):
return super().calculateCommission(baseSalary)
def displayData(self):
print('First name: ', self.FirstName)
print('Last name: ', self.LastName)
print('Age: ', self.Age)
print('Address: ', self.Address)
print('Contact number: ', self.ContactNumber)
print('Employee ID: ', self.EmployeeID)
print('Organization name: ', self.OrganizationName)
print('Position: ', self.Position)
print('Total earning: ', calculateTotalEarning(self, baseSalary))
Comments
Leave a comment