Skip to content

Instantly share code, notes, and snippets.

@meaganewaller
Created October 28, 2013 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meaganewaller/7198821 to your computer and use it in GitHub Desktop.
Save meaganewaller/7198821 to your computer and use it in GitHub Desktop.
PlayerFactory-SOLID
module TicTacToe
class PlayerFactory
def self.create(input)
case input[:type]
when :ai
AI.new(input[:mark])
when :human
Human.new(input[:mark])
else
raise "Invalid Player Type"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment