Created
July 29, 2013 17:53
Blindfolded code!
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 Game | |
def self.run! | |
deck = Deck.new | |
load_cards(deck) | |
until deck_is_finshed? | |
card = deck.deal_card | |
View.print_definition | |
process_user_input(card) | |
end | |
end | |
def self.process_user_input(card) | |
user_input = gets.chomp.downcase | |
if card.definition.downcase == user_input | |
card.mark! | |
View.print_correct_answer | |
else | |
View.print_incorect_answer | |
end | |
end | |
def self.load_cards(deck) | |
raw_data = [['whats the spanish for always?','siempre'], ['How old is jeff?','siempre']] | |
cards_array = raw_data.map do |definition| | |
Card.new(definition: definition.first, answer: definition.last) | |
end | |
cards_array.each do |card| | |
deck.add_card(card) | |
end | |
end | |
end | |
class View | |
def self.print_definition(definition) | |
puts defintion | |
end | |
def slef.print_correct_answer | |
puts "Your answer is correct!" | |
end | |
def self.print_incorect_answer | |
puts "Your answer is incorrect!" | |
end | |
end | |
Game.run! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment