연관(association)

Eunjung-Cho·2021년 5월 29일
0

class Course:
	def __init__(self, id, title, credit):
    	self.__c_id = id #원래 가지고 있던 attribute
        self.__c_title = title #원래 가지고 있던 attribute
        self.__credit= credit #원래 가지고 있던 attribute
        self.__inrolled_students = [] #aggregation 형태
        self.__instructor = None #aggregation 형태
	...
    def take_course(self, student):
    	self.__enrolled_students.append(student) #위에 있는 빈 리스트에다 append를 한다.
    def register_instructor(self, instructor):
    	self.__instructor = instructor # instructor 객체가 전달
profile
IT컨설팅 데이터 분석가

0개의 댓글