0% found this document useful (0 votes)
13 views

Library_Management_System_Project

lmsp

Uploaded by

Yash vema
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)
13 views

Library_Management_System_Project

lmsp

Uploaded by

Yash vema
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/ 10

College Project

Library Management System

Submitted by:

Name: Akash Sehdev

Course: MCA

College: BCIIT, GGSIPU

Submitted to:

Professor: [Name of Professor]

Department of Computer Science

Academic Year: 2024


Index

1. Introduction

2. Code Breakdown

3. Output

4. Conclusion
Introduction

This project demonstrates the development of a Library Management System using Python. The

system includes

modules for managing books, members, and library operations such as borrowing and returning

books. The

project is designed as an educational exercise to understand the concepts of object-oriented

programming

(OOP) and basic Python programming.


book.py

class Book:

def __init__(self, title, author, isbn, genre):

self.title = title

self.author = author

self.isbn = isbn

self.genre = genre

self.available = True

def borrow(self):

if self.available:

self.available = False

return "BORROWING SUCCESSFUL"

return "BORROWING UNSUCCESSFUL: Book is not available."

def return_book(self):

if not self.available:

self.available = True

return "BOOK RETURNED SUCCESSFUL"

return "RETURN UNSUCCESSFUL: Book was not borrowed."


member.py

class Member:

def __init__(self, name, member_id):

self.name = name

self.member_id = member_id

def borrow_book(self, book, library):

if book in library.book_list and book.available:

book.borrow()

return f"{self.name} has borrowed '{book.title}'."

return f"Borrowing unsuccessful. Either the book is not available or not found

in the library."

def return_book(self, book, library):

if book in library.book_list and not book.available:

book.return_book()

return f"{self.name} has returned '{book.title}'."

return f"Returning unsuccessful. Either the book was not borrowed or not found

in the library."
library.py

from book import Book

from member import Member

class Library:

def __init__(self):

self.book_list = []

self.member_list = []

def add_book(self, book):

if isinstance(book, Book):

self.book_list.append(book)

return f"Book '{book.title}' added to the library."

return "Error: Invalid book object."

def add_member(self, member):

if isinstance(member, Member):

self.member_list.append(member)

return f"Member '{member.name}' added to the library."

return "Error: Invalid member object."


main.py

from book import Book

from member import Member

from library import Library

# Initialize the library

my_library = Library()

# Add books

book1 = Book("1984", "George Orwell", "1234567890", "Dystopian")

book2 = Book("To Kill a Mockingbird", "Harper Lee", "0987654321", "Classic")

print(my_library.add_book(book1))

print(my_library.add_book(book2))

# Add members

member1 = Member("Alice", "M001")

member2 = Member("Bob", "M002")

print(my_library.add_member(member1))

print(my_library.add_member(member2))

# Borrow books

print(member1.borrow_book(book1, my_library))

print(member1.borrow_book(book2, my_library))

# Try borrowing an already borrowed book


print(member2.borrow_book(book1, my_library))

# Return books

print(member1.return_book(book1, my_library))

print(member1.return_book(book2, my_library))
Output

Adding Books:

Book '1984' added to the library.

Book 'To Kill a Mockingbird' added to the library.

Adding Members:

Member 'Alice' added to the library.

Member 'Bob' added to the library.

Borrowing and Returning:

Alice has borrowed '1984'.

Alice has borrowed 'To Kill a Mockingbird'.

Borrowing unsuccessful. Either the book is not available or not found in the library.

Alice has returned '1984'.

Alice has returned 'To Kill a Mockingbird'.


Conclusion

The Library Management System is a fundamental example of object-oriented programming in

Python.

It highlights the use of classes, methods, and objects to solve real-world problems. This project

serves

as a stepping stone to more complex systems and provides insight into designing modular and

scalable code.

You might also like