Last active
February 24, 2016 02:21
-
-
Save gilcierweb/f512be547434e2ca5577 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/ruby | |
# test gilcier | |
# In terminal execute ruby palindrome.rb | |
class String | |
def initialize(word) | |
@word = word.to_s.strip.downcase | |
end | |
def verify_word | |
if(@word == @word.reverse) | |
puts "#{@word} word is a palindrome!" | |
else | |
puts "#{@word} word is not a palindrome!" | |
end | |
end | |
end | |
puts "Tell how many words you want to check if it is a palindrome" | |
quantity = gets.to_s.strip.downcase.chomp | |
for count_current in 1..quantity.to_i do | |
puts "Enter a word ##{count_current}" | |
word = gets.to_s.strip.downcase.chomp | |
# Use | |
palindrome = String.new(word) | |
palindrome.verify_word | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment