Skip to content

Commit 8278e31

Browse files
author
Tusamma Sal Sabil
committed
Add Library Management System Relates Codes
1 parent d9da689 commit 8278e31

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
from abc import ABC, abstractmethod
2+
from .constants import *
3+
4+
5+
class Book(ABC):
6+
def __init__(self, ISBN, title, subject, publisher, language, number_of_pages):
7+
self.__ISBN = ISBN
8+
self.__title = title
9+
self.__subject = subject
10+
self.__publisher = publisher
11+
self.__language = language
12+
self.__number_of_pages = number_of_pages
13+
self.__authors = []
14+
15+
16+
class BookItem(Book):
17+
def __init__(self, barcode, is_reference_only, borrowed, due_date, price, book_format, status,
18+
date_of_purchase, publication_date, placed_at):
19+
self.__barcode = barcode
20+
self.__is_reference_only = is_reference_only
21+
self.__borrowed = borrowed
22+
self.__due_date = due_date
23+
self.__price = price
24+
self.__format = book_format
25+
self.__status = status
26+
self.__date_of_purchase = date_of_purchase
27+
self.__publication_date = publication_date
28+
self.__placed_at = placed_at
29+
30+
def checkout(self, member_id):
31+
if self.get_is_reference_only():
32+
print("self book is Reference only and can't be issued")
33+
return False
34+
if not BookLending.lend_book(self.get_bar_code(), member_id):
35+
return False
36+
self.update_book_item_status(BookStatus.LOANED)
37+
return True
38+
39+
40+
class Rack:
41+
def __init__(self, number, location_identifier):
42+
self.__number = number
43+
self.__location_identifier = location_identifier
44+
45+
46+
class BookReservation:
47+
def __init__(self, creation_date, status, book_item_barcode, member_id):
48+
self.__creation_date = creation_date
49+
self.__status = status
50+
self.__book_item_barcode = book_item_barcode
51+
self.__member_id = member_id
52+
53+
def fetch_reservation_details(self, barcode):
54+
None
55+
56+
57+
class BookLending:
58+
def __init__(self, creation_date, due_date, book_item_barcode, member_id):
59+
self.__creation_date = creation_date
60+
self.__due_date = due_date
61+
self.__return_date = None
62+
self.__book_item_barcode = book_item_barcode
63+
self.__member_id = member_id
64+
65+
def lend_book(self, barcode, member_id):
66+
None
67+
68+
def fetch_lending_details(self, barcode):
69+
None
70+
71+
72+
class Fine:
73+
def __init__(self, creation_date, book_item_barcode, member_id):
74+
self.__creation_date = creation_date
75+
self.__book_item_barcode = book_item_barcode
76+
self.__member_id = member_id
77+
78+
def collect_fine(self, member_id, days):
79+
None
80+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from abc import ABC
2+
3+
4+
class Search(ABC):
5+
def search_by_title(self, title):
6+
None
7+
8+
def search_by_author(self, author):
9+
None
10+
11+
def search_by_subject(self, subject):
12+
None
13+
14+
def search_by_pub_date(self, publish_date):
15+
None
16+
17+
18+
class Catalog(Search):
19+
def __init__(self):
20+
self.__book_titles = {}
21+
self.__book_authors = {}
22+
self.__book_subjects = {}
23+
self.__book_publication_dates = {}
24+
25+
def search_by_title(self, query):
26+
# return all books containing the string query in their title.
27+
return self.__book_titles.get(query)
28+
29+
def search_by_author(self, query):
30+
# return all books containing the string query in their author's name.
31+
return self.__book_authors.get(query)
32+

0 commit comments

Comments
 (0)