I'm new to programming so please bear with me if this is obvious.
I have two classes in the same *.py file. the snippets are below. I am trying to simulate a lift, with customers, and in the main program I will create n customers. I would like the method in the elevator class, called startLift to be able to access the individual instances of customer but I am unsure how to do this, so if I loop through my customers, calling the startLift on each iteration, how can I make it so it references this instance.
Thank you in advance.
class elevator:
def __init__(self):
self.stops = building.getFloors(redbrick)
if self.stops <1:
print "elevator out of bounds"
else:
print "elevator has ",building.getFloors(redbrick),"stops"
i try rephrase the question :
self.stops = building.getFloors(redbrick)
im calling the building method with in the elevator class, so the building passes information to the elevator class regarding how many floors it can travel.
"redbrick" is an instance of the buliding class, in order for that to work "building.getfloors() , i must pass an instance of the builiding in, or else i get
"unbound method getFloors() must be called with building instance as first argument (got nothing instead)"
but how do i pass in multiple instances of a building into "building.getfloors()if i create it e.g
whitebrick = building()
redbrick = building()
yellowbrick = building()
customer.getLocation(users). You'll probably want to pass in an instance of acustomerintostartLiftelevatorandcustomerare both classes. However, you want to create instances of each of those classes. It will be easier to help you if you add in your full code here, as this code will need some significant changes to work properly.