Skip to content

Instantly share code, notes, and snippets.

@nafidurmus
Last active July 26, 2019 11:26
Show Gist options
  • Save nafidurmus/63d1be4d6a8311ec15f789923c592f67 to your computer and use it in GitHub Desktop.
Save nafidurmus/63d1be4d6a8311ec15f789923c592f67 to your computer and use it in GitHub Desktop.
class Wand
def cast_spell
spell = get_new_spell
spell.cast!
end
def get_new_spell
raise "abstract method #get_new_spell must be defined"
end
end
class HarryPottersWand < Wand
def get_new_spell
WingardiumLeviosa.new
end
end
class SeverusSnapesWand < Wand
def get_new_spell
Crucio.new
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment