[英]How to solve error in this python code of polymorphism and inheritance
Class Employee is the parent class Employee 类是父类
Condition
if position=="Staff":
emp.dayWorked=input("Day worked in a month:")
//error
emp.pay()
emp.display()
elif position=="Executive":
exe.dayWorked=input("Day worked in a month:")
exe.pay()
emp.display()
elif position=="Clerks":
clk.dayWorked=input("Day worked in a month:")
clk.addHours=input("Overtime:")
clk.pay()
emp.display()
Please help me to solve the error I am a beginner and I do need a guide If can please add some comment line for me to understand easily请帮我解决错误我是初学者,我确实需要一个指南如果可以请添加一些注释行让我更容易理解
This a python program to calculate total salary of employee ,executive and clerks but have to use polymorphism and inheritance method as done.这是一个python程序,用于计算员工、行政人员和文员的总工资,但必须使用多态和继承方法。
//ERROR Traceback (most recent call last): File "C:/Users/User/PycharmProjects/lab8python/lt3.py", line 58, in emp.pay() File "C:/Users/User/PycharmProjects/lab8python/lt3.py", line 12, in pay return self.payRateself.hoursWorkedself.dayWorked AttributeError: 'Employee' object has no attribute 'payRate' //错误追溯(最近一次调用):文件“C:/Users/User/PycharmProjects/lab8python/lt3.py”,第58行,在emp.pay()文件“C:/Users/User/PycharmProjects/lab8python /lt3.py", line 12, in pay return self.payRateself.hoursWorkedself.dayWorked AttributeError: 'Employee' object has no attribute 'payRate'
Class Employee is the parent class Employee 类是父类
Condition
if position=="Staff":
emp.dayWorked=input("Day worked in a month:")
//error
emp.pay()
emp.display()
elif position=="Executive":
exe.dayWorked=input("Day worked in a month:")
exe.pay()
emp.display()
elif position=="Clerks":
clk.dayWorked=input("Day worked in a month:")
clk.addHours=input("Overtime:")
clk.pay()
emp.display()
Please help me to solve the error I am a beginner and I do need a guide If can please add some comment line for me to understand easily请帮我解决错误我是初学者,我确实需要一个指南如果可以请添加一些注释行让我更容易理解
This a python program to calculate total salary of employee ,executive and clerks but have to use polymorphism and inheritance method as done.这是一个python程序,用于计算员工、行政人员和文员的总工资,但必须使用多态和继承方法。
//ERROR Traceback (most recent call last): File "C:/Users/User/PycharmProjects/lab8python/lt3.py", line 58, in emp.pay() File "C:/Users/User/PycharmProjects/lab8python/lt3.py", line 12, in pay return self.payRateself.hoursWorkedself.dayWorked AttributeError: 'Employee' object has no attribute 'payRate' //错误追溯(最近一次调用):文件“C:/Users/User/PycharmProjects/lab8python/lt3.py”,第58行,在emp.pay()文件“C:/Users/User/PycharmProjects/lab8python /lt3.py", line 12, in pay return self.payRateself.hoursWorkedself.dayWorked AttributeError: 'Employee' object has no attribute 'payRate'
Class Employee is the parent class Employee 类是父类
Condition
if position=="Staff":
emp.dayWorked=input("Day worked in a month:")
//error
emp.pay()
emp.display()
elif position=="Executive":
exe.dayWorked=input("Day worked in a month:")
exe.pay()
emp.display()
elif position=="Clerks":
clk.dayWorked=input("Day worked in a month:")
clk.addHours=input("Overtime:")
clk.pay()
emp.display()
Please help me to solve the error I am a beginner and I do need a guide If can please add some comment line for me to understand easily请帮我解决错误我是初学者,我确实需要一个指南如果可以请添加一些注释行让我更容易理解
This a python program to calculate total salary of employee ,executive and clerks but have to use polymorphism and inheritance method as done.这是一个python程序,用于计算员工、行政人员和文员的总工资,但必须使用多态和继承方法。
//ERROR Traceback (most recent call last): File "C:/Users/User/PycharmProjects/lab8python/lt3.py", line 58, in emp.pay() File "C:/Users/User/PycharmProjects/lab8python/lt3.py", line 12, in pay return self.payRateself.hoursWorkedself.dayWorked AttributeError: 'Employee' object has no attribute 'payRate' //错误追溯(最近一次调用):文件“C:/Users/User/PycharmProjects/lab8python/lt3.py”,第58行,在emp.pay()文件“C:/Users/User/PycharmProjects/lab8python /lt3.py", line 12, in pay return self.payRateself.hoursWorkedself.dayWorked AttributeError: 'Employee' object has no attribute 'payRate'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.