Trying to create an object via a user's input

后端 未结 3 1276
隐瞒了意图╮
隐瞒了意图╮ 2021-01-07 15:36

I\'m trying to create an employee object via user input, but I\'m running into issues with my code. When I run this nothing happens and it\'s not throwing any e

3条回答
  •  一生所求
    2021-01-07 16:24

    I think you want something like this

    class employee(object):
        def __init__(self,name,pay_rate,monday,tuesday,wednesday,thursday,friday,saturday,sunday):
            self.name = name
            self.pay_rate = pay_rate
            self.monday = monday
            self.tuesday = tuesday
            self.wednesday = wednesday
            self.thursday = thursday
            self.friday = friday
            self.saturday = saturday
            self.sunday = sunday
        @staticmethod
        def create_from_rawinput():
            return employee(
            raw_input("Employee name:"),
            raw_input("Pay Rate:"),
            raw_input("Enter monday hours:"),
            raw_input("Enter tuesday hours:"),
            raw_input("Enter wednesday hours:"),
            raw_input("Enter thursday hours:"),
            raw_input("Enter friday hours:"),
            raw_input("Enter saturday hours:"),
            raw_input("Enter sunday hours:")
            )
    
    new_emp = employee.create_from_rawinput()
    

提交回复
热议问题