我试图bonus用实例变量添加参数(它将采用整数),self.pay并想用工人的姓名打印最终付款。但是,我无法打印增加的总付款
我想调用该方法rise()而不是从中返回任何内容,但我很困惑如何调用它并传递一个整数。
class Information:
def __init__(self,first,last,pay):
self.first = first
self.last = last
self.pay = pay
def rise(self,int(bonus)):
self.pay = self.pay + bonus
def __str__(self):
return "%s and %s and has a balance of %s" % (self.first,self.last,self.pay)
if __name__ == "__main__":
emp1 = Information("tom","jerry",999)
print (emp1)
哔哔one
繁星coding
相关分类