class Visitor:
def visit(self,elem):
pass
class NameVisitor(Visitor):
def visit(self,elem):
print(elem.name)
class AgeVisitor(Visitor):
def visit(self,elem):
print(elem.age)
class Cat:
def __init__(self,name,age):
self.name = name
self.age = age
def speak(self):
print("meow")
def accept(self,visitor:Visitor):
print("use implementation of visitor")
visitor.visit(self)