我有这个电梯任务,我被困在一个地方。我有一个包含客户列表的建筑对象。我正在尝试一种让客户进入电梯的方法 - 客户被附加到电梯列表中,但无法找到从建筑物列表中删除该客户的方法:尝试过del
但list.remove(item)
没有任何乐趣。谁能指出我正确的方向?
class building(object):
def __init__(self, floors = 0, customerNo = 0,):
self.floors = 0
self.myE = elevator()
self.customerNo = 0
self.customersWaiting = []
self.customersTransported = []
def initCustomers(self):
cnt = 1
cust = cnt
while cnt <= myB.customerNo :
floor = random.randint(0, self.floors - 1)
destination = random.randint(0, self.floors - 1)
cust = customer(cnt, floor , destination )
self.customersWaiting.append(cust)
cnt +=1
class customer(object):
def __init__(self,cnt, floor = 0, destination = 0):
self.cnt = cnt
self.floor = floor
self.destination = destination
def enterElevator(self):
for cust in myB.customersWaiting :
if myB.myE.lvl == self.floor :
myB.myE.customersIn.append(self)
#del cust(self)
#myB.customersWaiting.remove(self)
else:
pass