Created
October 29, 2012 16:33
-
-
Save gtcarlos/3974696 to your computer and use it in GitHub Desktop.
Questionário
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
def valida_questionario(confirmacao) | |
unless confirmacao.downcase == "sim" || confirmacao.downcase == "nao" | |
print "Responda apenas com Sim ou Nao. " | |
confirmacao = gets.chomp | |
valida_questionario(confirmacao) | |
end | |
if confirmacao.downcase == "nao" | |
print "Qual pergunta esta errada?\n" | |
perguntas() | |
elsif confirmacao.downcase == "sim" | |
print "Obrigado" | |
end | |
end | |
def perguntas | |
print "1-\) Qual o seu nome? " | |
first_name = gets.chomp | |
first_name.capitalize! | |
print "2-\) E qual o seu sobrenome? " | |
last_name = gets.chomp | |
last_name.capitalize! | |
print "3-\) E de qual cidade voce e? " | |
city = gets.chomp | |
city.capitalize! | |
print "4-\) E de qual estado voce e? " | |
state = gets.chomp | |
state.upcase! | |
while state.length != 2 | |
print "4-\) Escreva apenas as siglas do seu Estado. " | |
state = gets.chomp | |
state.upcase | |
end | |
puts "Entao seu nome e #{first_name} #{last_name} e voce e de #{city} e do estado de #{state}, estou certo?" | |
confirm = gets.chomp | |
valida_questionario(confirm) | |
end | |
if __FILE__ == $0 | |
perguntas() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment