방문자 패턴을 사용하여 첫 번째 클래스에서 self.coin 값을 가져 와서 두 번째 클래스의 메서드로 반환하지만 작동하지 않는 경우 항상 반환 없음 ... 아무도 도와 줄 수 있습니까?pygame - 방문자 패턴을 가진 변수를 가져 오는 파이썬
class coin_collector(Observer):
def __init__(self):
super(Observer, self).__init__()
self.coin_count = 0
self.run = True
self.coin = 0
def acceptVisitor(self, visitor):
visitor.visit(self)
def update(self, observable, other):
me = coin_collector()
me.coin_Count(other, True)
def coin_Count(self, value, TF):
run = TF
if run:
self.coin = value
print self.coin
return self.coin
def __str__(self):
return self.__class__.__name__
#this is part of a different class in a different file
def visit(self, location):
location.coin_Count(0, False)
def update(self):
visitee = coin_collector()
self.c_Count = self.visit(visitee) # for some reason this always returns none
print self.c_Count, "working" # this always prints none...
반환 할 것으로 예상되는 것은 무엇입니까? –