Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Library(object):
- def __init__(self, book):
- self.book = book
- def add_item(self, book):
- mylist.append(book)
- return mylist
- if __name__ == '__main__':
- booklist = []
- Book1 = Book(1, 'Bookname1', "$30")
- Book2 = Book(2, 'Bookname2', "$10")
- Book1.show()
- Book1.get_attribute_string()
- class Book(object):
- def __init__(self, ID, name, price):
- self.ID = ID
- self.name = name
- self.price = price
- def show(self):
- print(self.ID, self.name, self.price)
- def get_attribute_string(self):
- print(str(self.ID) + '_' + str(self.name) + '_' + str(self.price))
- def get_id(self):
- print(self.ID)
- def get_name(self):
- print(self.name)
- def get_price(self):
- print(self.price)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement