# 페이스북, 트위터, 인스타그램과 같은 SNS를 클래스를 통해서 구현해 보세요.
# 이번 시간에는 중요한 기능 중 하나인 좋아요를 추가해 봅시다.
class User:
def __init__(self, name):
self.name = name
# 게시글의 정보를 저장하는 클래스예요.
class Post:
# 멤버변수를 초기화하는 메서드예요.
def __init__(self, author, content):
self.author = author
self.content = content
# 좋아요를 누른 사용자를 저장하기 위한 빈 리스트를 정의해 주세요.
self.likes = None
# 좋아요를 누른 사용자의 수를 반환하는 num_likes() 메서드를 정의해 주세요.
# 사용자를 likes 리스트에 추가하는 like() 메서드를 정의해 주세요.
# Post 클래스를 테스트하기 위한 코드예요.
# 자유롭게 수정해 보세요.
To embed this project on your website, copy the following code and paste it into your website's HTML: