Last active
August 29, 2015 14:16
-
-
Save jonathanenlared/427665c24871746d580d 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
def ask_coord | |
valid = true | |
while valid | |
print "Introduzca la coordenada en formato fila,columna (ejemplo -> 1,4): " | |
coord = gets.chomp.split(',') | |
puts coord | |
for i in 0...2 | |
coord[i] = coord[i].to_i | |
end | |
if coord.length != 2 | |
puts "Coordenada invalida." | |
redo | |
elsif (coord[0] > 4 || coord[0] < 0) || (coord[1] > 4 || coord[1] < 0) | |
puts "Coordenada invalida." | |
redo | |
end | |
valid = false | |
return coord | |
end | |
end | |
def main | |
ask_coord | |
put ask_coord | |
end | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment