我正在尝试编写一个获取员工姓名,idNumber,班次号码和工资率的程序。我已将程序写入T,但现在当我调用get__方法时,它不会填充它只显示“get_employeeNumber和get__employeeName”方法而不是我的“get__ShiftNumber和get__payRate”。
有人能帮助我吗?
class Employee:
def __init__(self,employeeName, employeeNumber):
self.__employeeName = employeeName
self.__employeeNumber = employeeNumber
def set_employeeName(self, employeeName):
self.__employeeName = employeeName
def set_employeeNumber(self,employeeNumber):
self.employeeNumber = employeeNumber
def get_employeeName(self):
return self.__employeeName
def get_employeeNumber(self):
return self.__employeeNumber
class ProductionWorker(Employee):
def __init__ (self,employeeName, employeeNumber, shiftNumber, payRate):
Employee. __init__ (self,employeeName,employeeNumber)
#intialize the shift number
self.__shiftNumber = shiftNumber
#intialize the pay rate
self.__payRate = payRate
def set_shiftNumber(self,shiftNumber):
self.__shiftNumber = shiftNumber
def set_payRate(self,payRate):
self.__payRate = payRate
def get_shiftNumber(self):
return self.__shiftNumber
def get_payRate(self):
return self.__payRate
我的主要功能:
import ce_classEmployee11_1
def main():
print(' ', 'Production Worker Information')
print('--------------------------------------------------------------------------------')
print('Name',' ', 'ID Number',' ', 'Shift Number', ' ', 'Worker Pay')
print('--------------------------------------------------------------------------------')
workName = input('Enter the worker name:')
idNumber = int(input("Enter {}".format(workName) + 'ID number'))
shiftValue = int(input("Enter {}". format(workName) + 'shift number'))
hourRate = int(input('Enter {}'. format(workName) + 'hourly rate:'))
myEmployee = ce_classEmployee11_1.ProductionWorker(workName,idNumber,shiftValue,hourRate)
print(myEmployee.get_employeeName(), ' ', myEmployee.get_employeeNumber())
print(myEmployee.get_shiftValue())