SHARE
TWEET

library object oriented design

a guest Jan 20th, 2020 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from abc import ABC, abstractmethod
  2.  
  3.  
  4. class Item(ABC):
  5.     def __init__(self):
  6.         pass
  7.  
  8.  
  9. class Book(Item):
  10.     def __init__(self, title, author, genre, publish_date):
  11.         self.title = title
  12.         self.author = author
  13.         self.genre = genre
  14.         self.publish_date = publish_date
  15.  
  16.  
  17. class BookCopy(Book):
  18.     def __init__(self, title, author, genre, publish_date, copy_id):
  19.         super().__init__(title, author, genre, publish_date)
  20.         self.copy_id = copy_id
  21.         self.is_reserved = False
  22.         self.is_rented = False
  23.  
  24.  
  25. class InvertedIndex:
  26.     def __init__(self):
  27.         pass
  28.    
  29.     def construct_index(self):
  30.         pass
  31.    
  32.     def add_book_to_index(self):
  33.         pass
  34.  
  35.  
  36. class Rack:
  37.     def __init__(self, capacity, rack_id):
  38.         self.capacity = capacity
  39.         self.rack_id = rack_id
  40.         self.rack_spot_map = {}
  41.    
  42.     def store_book_copy(self, book_copy):
  43.         available_spot = self.get_available_spot()
  44.         available_spot.store(book_copy)
  45.         self.rack_spot_map[book_copy.copy_id] = available_spot.rack_spot_id
  46.    
  47.     def get_available_spot(self):
  48.         return
  49.  
  50.  
  51. class Inventory:
  52.     def __init__(self):
  53.         pass
  54.    
  55.     def add_book_copies(self, copies):
  56.         pass
  57.    
  58.     def search_book(self, parameters):
  59.         pass
  60.    
  61.  
  62. class RentalHistory:
  63.     def __init__(self):
  64.         # member, copy, checkout, expected return, actual return
  65.         pass
  66.  
  67.  
  68. class Transactions:
  69.     def __init__(self):
  70.         # transactionId, memberid, transaction, amount_change, total_amount
  71.         pass
  72.  
  73.  
  74. class Member:
  75.     def __init__(self, name, member_id):
  76.         self.name = name
  77.         self.member_id = member_id
  78.         self.books_rented = []
  79.         # memberid, name, books rented
  80.    
  81.     def search_book(self, parameters):
  82.         pass
  83.    
  84.     def rent_book(self, book):
  85.         pass
  86.    
  87.     def reserve_book(self, book):
  88.         pass
  89.  
  90.  
  91. class IdGeneratorService:
  92.     def generate(self):
  93.         import time
  94.         return time.time()
  95.  
  96.  
  97. class Library:
  98.     def __init__(self, name):
  99.         self.name = name
  100.         self.inventory = Inventory()
  101.         self.transactions = Transactions()
  102.         self.rentalHistory = RentalHistory()
  103.         print("Hi Welcome to library")
  104.    
  105.     def search_book(self, parameters):
  106.         return self.inventory.search_book(parameters)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top