OOP
Object-oriented programming (OOP) concepts using Python pseudocode and UML diagrams.
Aggregation
+----------------+ +----------------+
| Library |<>---->| Book |
+----------------+ +----------------+
| - books: List | | - title: str |
| + add_book() | | - author: str |
+----------------+ +----------------+
class Book:
def __init__(self, title, author):
self.title = title
self.author = author
class Library:
def __init__(self):
self.books = []
def add_book(self, book):
self.books.append(book)
# Example usage
library = Library()
book1 = Book("1984", "George Orwell")
library.add_book(book1)Composition
Uses (Dependency)
Inheritance
Last updated