Last active
May 4, 2018 03:55
-
-
Save mgiagante/bb06e33bfb54c2da65c78fcc1d6889c8 to your computer and use it in GitHub Desktop.
Encapsulation example for my object-oriented programming series in medium.com
This file contains hidden or 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 Dragon | |
def initialize | |
# ... | |
end | |
def fly | |
take_off | |
100.times do | |
move_wings(:horizontally) | |
end | |
land | |
end | |
private | |
def take_off | |
10.times do | |
move_wings(:vertically) | |
end | |
end | |
def move_wings(direction) | |
# ... | |
end | |
def land | |
# ... | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment