2.8.1.4 Association
Python Programming
Association represents a relationship between two classes. There are two types of association:
- Aggregation: Represents a relationship where one class (e.g., Library) contains another class (e.g., Book) but does not own it. Books can exist independently of the library.
python
class Book :
def __init__(self , title):
self.title = title
class Library :
def __init__(self ) :
self.books = [ ]
def add_book(self, book):
self.books