Created
February 28, 2013 18:06
-
-
Save mikelbring/5058786 to your computer and use it in GitHub Desktop.
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 LearnMyABCs | |
def initialize | |
@letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] | |
end | |
def speak(text) | |
puts text | |
system 'say ' + text | |
end | |
def type_letter(letter) | |
self.speak('Please type the letter ' + letter) | |
input = gets.chomp | |
# to prevent rapid enter pressing - darn kids | |
until input[0] != nil | |
input = gets.chomp | |
end | |
# just get the first letter, incase of multiple letter inputs | |
if input[0,1].upcase == letter | |
self.speak('Good Job') | |
else | |
speak('Try again') | |
self.type_letter letter | |
end | |
end | |
def start() | |
for letter in @letters.shuffle | |
self.type_letter letter | |
end | |
speak('Nice work, you went through the entire alphabeta.'); | |
end | |
end | |
LearnMyABCs.new.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment