My Projects

 6. A Simple Library Management System

#  making a class
class library:
    memory = []
    def __init__(self,*books):
        self.shelf = []
        self.no_of_books=0
        for index,i in enumerate(books):
            self.shelf.append(books[index])
            self.no_of_books+=1
    def showbooks(self):
        print(f'books are {",".join(self.shelf)}'.title())
    def show_quantity_books(self):
        print(f'no of books: {self.no_of_books}'.title())
    @classmethod
    def showstoresinfo(self):
        print(library.memory)
class updated_library(library):
    def add_books(self,*newbooks):
     for index,i in enumerate(newbooks):
        self.shelf.append(newbooks[index])
        self.no_of_books+=1
    def add_book(self,book):
        self.shelf.append(book)
    def check_no_books(self):
        if self.no_of_books==len(self.shelf):
            return 'No problem in program'
        else:
            return 'Error occured in program'
    @classmethod
    def StoreBooksName(self,*books):
        for book in books:
            library.memory.append(book)
        print(f'\nstored,here is a view... \n{library.memory}')
   
a=updated_library('alchemist','robinson crusoe',"To Kill a Mockingbird","The Catcher in the Rye")
# a.add_books('the pilgrimage','alchemist')
# a.showbooks()
print(dir(updated_library))
a.StoreBooksName('alchemist')
a.showstoresinfo()

Comments

Popular posts from this blog

Advance Calculator Made For Mathematicans and Coders | Made with Python

My Projects

Functions Module