I've got a loop setup that asks for an employee name, hourly wage, and number of hours worked. Then at the end of the loop it creates an object containing that info.
Then I tried to use a property to change the employees name, but I get an error saying it isn't callable. If someone could point me in the right direction that would be great.
Here's my code:
class employeeInfo(object):
"""This is the Employee Payroll class"""
def __init__(self, employee = "", hours = 0, pay = 0):
self.employee = employee
self.hours = hours
self.__pay = pay
self.employeeStats = self.employee, self.hours, self.__pay
#print self.employeeStats
def getEmp(self):
return self.employee
def setEmp(self, newEmp = ""):
self.employee = newEmp
employeed = property(getEmp, setEmp)
###mainline###
payRoll = True
while payRoll:
employees = []
employeeName = raw_input("Please enter the employee's first and last name: \n")
employeeName = employeeName.title()
if employeeName == "Done":
payRoll = False
elif len(employeeName) == 0:
print "You entered nothing.\n"
else:
#employeeInfo.employeed = raw_input("Please enter an alternate name for the employee: \n")
workedHours = int(raw_input("How many hours did the employee work?\n"))
if workedHours < 1 or workedHours > 60:
print "Employees can only work between 1 and 60 hours. Please try again."
else:
payRate = float(raw_input("What is the employee's hourly wage?\n"))
if payRate < 6.00 or payRate > 20.00:
print "Employee can only earn between $6.00 and $20.00 an hour. Please try again."
else:
objEmployee = employeeInfo(employee = employeeName, hours = workedHours, pay = payRate)
print objEmployee.employeed
altName = raw_input("Enter an alternate name for the employee: \n")
objEmployee.employeed(newEmp = altName)
print objEmployee.employeed


Sign In
Create Account



Back to top









