0% found this document useful (0 votes)
11 views3 pages

Class

The document presents a Python implementation of classes related to books, including 'Book', 'BorrowableBook', and 'ReferenceBook'. Each class has methods for displaying book information and managing borrower details. Sample instances of each class are created and their information is displayed.

Uploaded by

aaak85182
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

Class

The document presents a Python implementation of classes related to books, including 'Book', 'BorrowableBook', and 'ReferenceBook'. Each class has methods for displaying book information and managing borrower details. Sample instances of each class are created and their information is displayed.

Uploaded by

aaak85182
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Faculty Of Information Technology

Elmergib University

Solving The Assignment Of OOP

Name: Alaa Khalifa Abdelali


RN: 20218001
class Book:
def __init__(self, title, author, ISBN):
self.title = title
self.author = author
self.ISBN = ISBN

def display_info(self):
print(f"Book: {self.title}\n Author: {self.author} \n ISBN: {self.ISBN}")

class BorrowableBook(Book):
def __init__(self, title, author, ISBN, borrower_name, due_date):
super().__init__( title, author, ISBN)
self.__borrower_name = borrower_name
self.due_date = due_date

def get_borrower_name(self):
return self.__borrower_name

def set_borrower_name(self, new_borrower_name):


self.__borrower_name = new_borrower_name

def display_info(self):
super().display_info()
print(f"Borrower name: {self.__borrower_name}\n Due date: {self.due_date}")

class ReferenceBook(Book):
def __init__(self, title, author, ISBN, room_number):
super().__init__( title, author, ISBN)
self.room_number = room_number

def display_info(self):
super().display_info()
print(f"Room number: {self.room_number} ")

book1 = Book("Python Basics", "John Doe", "123-456")


book2 = Book("Open", "Andre Agassi", "0307-978")

book_br1 = BorrowableBook("Data Science Essentials", "Alice Smith","780-101","Alice",


"15/12/2024")
book_br2 = BorrowableBook("The Alchemist", "Paulo Coelho","978-0061122415","Alen",
"31/12/2024")
book_re1 = ReferenceBook("Machine Learning Handbook", "Bob Lee", "112-233", 205)
book_re2 = ReferenceBook("Encyclopedia of Computer Science ", "Anthony Ralston", "978-
0470864128", 202)

book1.display_info()
book2.display_info()
print("\nBorrowable Book:")

book_br1.display_info()
book_br2.display_info()

print("\nReference Book:")

book_re1.display_info()
book_re2.display_info()

You might also like