Skip to content

Instantly share code, notes, and snippets.

@raeq
Last active May 16, 2020 19:20
Show Gist options
  • Save raeq/e721dc9cc8f8e5cbc9c5430bc89c2fe1 to your computer and use it in GitHub Desktop.
Save raeq/e721dc9cc8f8e5cbc9c5430bc89c2fe1 to your computer and use it in GitHub Desktop.
"""
A simple class example.
"""
class Book:
"""
A simple book class.
"""
def __init__(self, isbn: str, title: str, author: str):
"""
The constructor
"""
self.isbn = isbn
self.title = title
self.author = author
self.page = 0
self.notes = []
def set_note(self, note: str, page: int)-> int:
"""
Sets a reader note.
"""
self.notes.append((note, page))
def goto_page(self, page_number: int):
"""
Sets the current page number. Maximum of 1000.
"""
if page_number < 1000 > 0:
self.page = page_number
def __repr__(self) -> str:
return f"Object id: {id(self)}. Author: {self.author}. Title: {self.title}. ISBN: {self.isbn}."
mybook: Book = Book(author="K Heckenlively", isbn="1510752242", title="Restoring Faith in ... Science")
print(mybook)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment