National University of Sciences & Technology
(NUST)
School of interdisciplinary Engineering & Sciences (SINES)
BS Bioinformatics (3rd Semester)
Course: Object Oriented Programming (CS-212)
Assignment 1
Submitted To:
Dr Usman Shahid
Submitted By:
Areeba Amjad (503173)
Question 1:
Create a Person class. Include attributes like name, country, and date of birth. Show
the class using a diagram. Also, write a Python code for the class and implement a
method to determine the person's age.
Diagram:
Python code:
Output:
Question 2:
A book is associated with many authors and an author can write many books. Draw
the class diagram and write a Python code to demonstrate this association.
Diagram:
It is a simple 2 way association between author and book with many-many
relationship.
Author
Book
+name: str
+email: str
+title: str
+no_of_pages
+write_book(book)
n
n
+add_author(author)
Python Code:
Output: