Created
April 18, 2016 18:29
-
-
Save wray/707297e73e401d01329b87060b48ddbf to your computer and use it in GitHub Desktop.
Book
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Book: | |
def __init__(self,pages): | |
self.pages = pages | |
self.current_page = 0 | |
self.bookmark = 0 | |
def read(self): | |
return self.current_page | |
def turn_page(self): | |
self.current_page += 2 | |
return self.current_page | |
def next_page(self): | |
self.current_page += 1 | |
return self.current_page | |
def prev_page(self): | |
self.current_page -= 1 | |
return self.current_page | |
def open_to_bookmark(self): | |
return self.bookmark | |
def set_bookmark(self,bookmark): | |
self.bookmark = bookmark | |
def goto_page(self,page): | |
self.current_page = page | |
self.read() | |
class Reference(Book): | |
def __init__(self,pages,sections): | |
self.sections = sections | |
Book.__init__(self,pages) | |
def goto_section(self,topic): | |
self.current_page = self.sections[topic] | |
return self.current_page | |
ref_book = Reference(700,{"plants":1,"animals":200}) | |
ref_book.goto_section("animals") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment