Return to Snippet

Revision: 49359
at July 20, 2011 20:54 by marcos_sanchez


Initial Code
$x = 0 
$y = 0

def moverderecha(metros)
	$x = $x + metros
	
end
def moverizqierda(metros)
	$x = $x - metros
end
def moverarriba(metros)
	$y = $y + metros
end
def moverabajo(metros)
	$y = $y - metros
end

puts "cuantos metros quieres moverte"
metros = gets.chomp.to_i
puts "en que direccion"
puts"1 derecha"
puts"2 izquierda"
puts"3 arriba"
puts"4 abajo"
direccion = gets.chomp.to_i
if direccion == 1
	moverderecha(metros)

elsif direccion == 2
	moverizquierda(metros)
elsif direccion == 3
	moverarriba(metros)
elsif direccion == 4
	moverabajo(metros)
end
puts "tu posicion actual es x = #{$x} y = #{$y}"

Initial URL


Initial Description
le dices los metros y la dirección y te indica la posicion

Initial Title
indicador de posicion

Initial Tags


Initial Language
Ruby