Skip to content

Instantly share code, notes, and snippets.

@luizfonseca
Created May 4, 2012 03:07
Show Gist options
  • Save luizfonseca/2591648 to your computer and use it in GitHub Desktop.
Save luizfonseca/2591648 to your computer and use it in GitHub Desktop.
Friendly Robots (somewhere in 2010?)
#!/usr/bin/env ruby
class FriendlyRobots
$num_test_case = nil
$test_case = Array.new
def get_num_test_case
puts "How fast can the robots complete the hallway?"
puts "Please, input the test case: (an integer value)"
$num_test_case = gets.to_i
if $num_test_case > 0 then
return self
end
end
def run_test_case
i = 1
values = Array.new
puts "Here will follow the number of the test case you typed."
1.upto($num_test_case) do
puts "type the line number #{i}"
$test_case[i] = gets.to_i
i += 1
end
end
def get_position
puts "The current test case is #{$num_test_case}"
$test_case.each do |t|
puts "test case num #{t}"
end
end
def execute_test
self.run_test_case
self.get_position
end
end
input = FriendlyRobots.new
input.get_num_test_case.execute_test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment