我的代码出了什么问题?当我创建一个新的Boss类时,我似乎无法从员工那里获得所有参数。
months = 6
class Employee(object):
balance = 0
company_income = 10000000000000000
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.pay = pay
self.tasks = {}
self.fullname = "{} {}".format(self.first, self.last)
self.email = "{}.{}@Otterstad.com".format(self.first, self.last)
def finishTask(self, task):
del self.tasks[task]
def getMonths(self):
print self.pay * months
class Manager(Employee):
def __init__(self, first, last, pay):
super().__init__(first, last, pay)
self.employees = []
self.pay += 10000
def addTask(self, task):
if len(self.tasks) == 0:
self.tasks[1] = task
else:
self.tasks[len(self.tasks)+1] = task
class Boss(Employee):
def __init__(self, first, last, pay):
super().__init__(first, last, pay)
self.employees = []
def changeSalary(self, new_salary):
self.pay = new_salary
def giveBonus(self, bonus, employee):
employee.balance += bonus
def addTask(self, task):
if len(self.tasks) == 0:
self.tasks[1] = task
else:
self.tasks[len(self.tasks)+1] = task
st1 = Boss("test", "test", 2000000000)
答案 0 :(得分:0)
您正在以适合Python 3的方式调用Boss.__init__
,而不是2.
在super().__init__(first, last, pay)
中,更改
super(Boss, self).__init__(first, last, pay)
到
super
。
同样,在整个代码中将其他调用更改为//given two functions ( in a math way) f1,f2
var compared=f1(0)<f2(0);
var intersections=[];
for(range=0;range<1000;range+=0.001){
if(compared!==(f1(range)<f2(range))){
intersections.push(range);
compared!=compared;
}
}
。