Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Library Management System that was assigned #921

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions automated_library_management/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Library Management System


- It is a simple system that can record previous and future records of a reader by its own.
- It can also show the number of books left in the library and much more.

## Setup instructions

There is no need to import any kind of library for this script. It is simply build via applications of OOPS

## Detailed explanation of script

The system internally uses applications of dictionary data structure and can store the data in primary location for an instance. One can easily use this script to enhance the functionality of any basic script. It is a readable program which does not require any other outside python libraries.

## Output

<a href="https://ibb.co/7bRYBps"><img src="https://i.ibb.co/nRng41x/Screenshot-20221021-215934.png" alt="Screenshot-20221021-215934" border="0"></a>

## Author(s)

Daksh Raghuvanshi - https://github.com/Daksh-Raghuvanshi
99 changes: 99 additions & 0 deletions automated_library_management/library-management-system.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# A basic program for library management

class Library:
def __init__(self ,bookList , accountdetails):
self.bookList = bookList
self.accountdetails = accountdetails

def libraryStatus(self):
finalList = "\n".join(self.bookList)
print(f"\nAvalaible books for now are as follows-")
print("\n" , finalList)

def bookReturn(self , bookName):
self.bookList.append(bookName)
print(f"Thanks for returning or donating {bookName}, have a good day")

def borrowBook(self , bookName1):
if bookName1 in self.bookList:
self.bookList.remove(bookName1)
print(f"\nYou have been issued {bookName1} , please return it in 30 days .")
return True
else:
print(f"Sorry , {bookName1} is not available for now.")
return False

def policy(self):
print(f"""----------POLICIES----------
1) The book issued should be returned in 30 days from the date of issueing.
2) Charges are applied to the late returner.
3) Keep scilence while you are in the library.
4) You are not allowed to use foul language in the library .""")

def accountOpen(self , studentName , bookName2):
if bookName2 in self.bookList:
self.bookList.remove(bookName2)
b = {(studentName) : (bookName2) }
self.accountdetails.update(b)
print(f"Your account has been opened successfully.")
else:
print(f"Sorry {bookName2} is not available for now.")

def getDetails(self):
print(f"People with the book they ever borrowed(member of this library):\n{self.accountdetails}")

class Student:
def studentName(self):
self.name = input("Please enter your name: ")
return self.name

def requestBook(self):
self.book = input("\nPlease enter the name of the book you want to borrow: ")
return self.book

def returnBook(self):
self.book = input("\nPlease enter the name of the book you want to return or donate: ")
return self.book



if __name__ == "__main__":
dakshLibrary = Library(["Harry Potter" , "Physics and Matter" , "Black Hole" , "Python" , "HC V" , "Do Epic Shit"] , {"Rohan" : "Words" , "Shubham" : "Scilence" , "Shibu" : "Time Travel"})
student = Student()
while(True):
welcomemsg = '''\n ====== Welcome to People's Library ======
Please choose an option:
1. List all the books
2. Request a book
3. Return/Donate a book
4. Account Opening
5. Accout Details
6. Policies of the Library
7. Exit the Library
'''
print (welcomemsg)
a = int(input("Enter a choice: "))
if a == 1:
dakshLibrary.libraryStatus()

elif a == 2:
dakshLibrary.borrowBook(student.requestBook())

elif a == 3:
dakshLibrary.bookReturn(student.returnBook())

elif a == 4:
dakshLibrary.accountOpen(student.studentName(), student.requestBook())

elif a == 5:
dakshLibrary.getDetails()

elif a == 6:
dakshLibrary.policy()

elif a == 7:
print(f"\nThanks for choosing People's Library , visit again")
exit()

else:
print(f"Invalid choice , please enter a choice from the given data.")