Skip to content

Instantly share code, notes, and snippets.

@mysticBliss
Created February 25, 2018 14:25
Show Gist options
  • Save mysticBliss/b45a52524cd0fad47284b9a6c42f3be1 to your computer and use it in GitHub Desktop.
Save mysticBliss/b45a52524cd0fad47284b9a6c42f3be1 to your computer and use it in GitHub Desktop.
Basics Of-OOPS
# Library
# Abstractions-- list of books, lendbook, addbook, removebook

# Student
# - order book 
# - return book

class Library:
    def __init__(self):
        self.BookList=['Book1','Books2','Books3']
    
    def displayBooks(self):
        return self.BookList
    
    def lendbook(self,vlendbook):
        if vlendbook in self.BookList:
            print
            print('Issuing Book')
            print
            self.BookList.remove(vlendbook)
        else:
            print
            print('Book not available')
            print
    
    def addBook(self,vaddBook):
        print
        self.BookList.append(vaddBook)
        print
        print('Returned Book - Thanks')
        print
        
class Student:
    def issueBook(self):
        print
        self.requestBook=str(raw_input("Enter book name:"))
        print
        return str(self.requestBook)
    
    
    def returnBook(self):
        print
        self.returnbook=str(raw_input("return book named as:"))
        return self.returnbook
        
        
library = Library()
saqib=Student()    

    
while True:
    
    print
    print('=========================')
    print('PRESS 1 for list of books')
    print('PRESS 2 for request a book')
    print('PRESS 3 for return a book')
    print('PRESS 4 for to EXIT')
    print('=========================')
    
    choice=input("Enter Choice:")
    
    if choice==1:
        print(library.displayBooks())
        
    elif choice==2:
        requestedBook=saqib.issueBook()
        print requestedBook
        
        library.lendbook(requestedBook)    
            
    elif choice==3:
        returnedBook=saqib.issueBook()
        library.addBook(returnedBook)
        
    elif choice==4 :
        quit()
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment