I'm trying to build a program that will ask how many people, create an object for each person, and take separate information from the user(ex. name, weeklyhrs, wage) for each object. That way I can simply enter information about employees and a different function can calculate salary for each one.
So far I have only been able to create two separate objects and classes for each person and would have to add each person manually to do more than one. Also as of now this only allows me to have 2 people. I would like to ask the user how many people and then have an object for each with its own individual variables/information.
class SalesPerson1:
def __init__(self, name1 = '', weeklyhrs1 = 0, wage1 = 0):
self.name1 = input('Enter the first employees name?')
self.weeklyhrs1 = input('Enter the first employees number of weekly hours?')
self.wage1 = input('Enter the first employees weekly wage?')
def salesPerson1(self):
return self.name1
return self.weeklyhrs1
return self.wage1
class SalesPerson2:
def __init__(self, name2 = '', weeklyhrs2 = 0, wage2 = 0):
self.name2 = input('Enter the second employees name?')
self.weeklyhrs2 = input('Enter the second employees number of weekly hours?')
self.wage2 = input('Enter the second employees weekly wage?')
def salesPerson2(self):
return self.name2
return self.weeklyhrs2
return self.wage2
person1 = SalesPerson1()
person2 = SalesPerson2()