18.12 연습문제
연습문제 18-1
다음 프로그램에 대해서 클래스와 클래스의 관계를 보여주는 UML 클래스 다이어그램을 그려라.
class PingPongParent:
pass
class Ping(PingPongParent):
def _ _init_ _(self, pong):
self.pong = pong
class Pong(PingPongParent):
def _ _init_ _(self, pings=None):
if pings is None:
self.pings = []
else:
self.pings = pings
def add_ping(self, ping):
self.pings.append(ping)
pong = Pong()
ping = Ping(pong)
pong.add_ping(ping)