I want to call a method of class A, from class B; but I get an error which I do ot understand.
Can anyone help me resolve my issue?
Here’s my code and error:
self.loc1_ = ‘A’
self.loc2_ = ‘B’
self.state_ = state
def setloc1_state(self,state): #state='D' self.state_ = state
self.percept_ = percept
self.cost_ = 0
self.location_ = location
self.action_ = action
self.goal_ = goal
def clean(self): place = self.getlocation() if place == 'A': Environment.setloc1_state(self,'C') if place == 'B': Environment.setloc2_state(self,'C')
init_state = [‘D’,‘D’]
house = Environment(init_state) vacuum = Agent(percept=house.getstate(),location='A') while house.getstate() != ['C','C']: vacuum.execute_action(house.getstate()) print(house.getstate())
I get this error:
AttributeError: ‘Agent’ object has no attribute ‘state_’; related to this line of the clean() function:
I read several tutorials which explains this concept ofcalling class members from another class, and those examples worked. So, I’m not sure why this code snippet does not distinguish between the “self” variabble linked to the 2 different classes.
Please educate me?