Created
November 23, 2018 22:25
-
-
Save VladHurma/408704cc913a59089340304de9bc9cc0 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 If_word_palindrome | |
def initialize | |
@checkup = false | |
end | |
def self.run | |
new.run | |
end | |
def run | |
ask_user_for_word | |
check_word | |
tell_user_about_palindrome | |
end | |
private | |
def ask_user_for_word | |
puts "Enter your word for checking, if this word is palindrome!" | |
@word = gets.strip | |
end | |
def check_word | |
if @word == @word.reverse | |
@checkup = true | |
end | |
end | |
def tell_user_about_palindrome | |
if @checkup == true | |
puts "#{@word} is palindrome!" | |
else | |
puts "#{@word} isn't palindrome!" | |
end | |
end | |
end | |
If_word_palindrome.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ну либо
Либо
Тогда мы сделаем, если я не ошибаюсь
И будет все работать