Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. class Library(object):
  2.  
  3. def __init__(self, book):
  4. self.book = book
  5.  
  6. def add_item(self, book):
  7. mylist.append(book)
  8. return mylist
  9.  
  10.  
  11. if __name__ == '__main__':
  12. booklist = []
  13. Book1 = Book(1, 'Bookname1', "$30")
  14. Book2 = Book(2, 'Bookname2', "$10")
  15. Book1.show()
  16. Book1.get_attribute_string()
  17.  
  18. class Book(object):
  19.  
  20. def __init__(self, ID, name, price):
  21. self.ID = ID
  22. self.name = name
  23. self.price = price
  24.  
  25. def show(self):
  26. print(self.ID, self.name, self.price)
  27.  
  28. def get_attribute_string(self):
  29. print(str(self.ID) + '_' + str(self.name) + '_' + str(self.price))
  30.  
  31. def get_id(self):
  32. print(self.ID)
  33.  
  34. def get_name(self):
  35. print(self.name)
  36.  
  37. def get_price(self):
  38. print(self.price)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement