Commit 95301ec

mo k <mo@mokhan.ca>
2012-08-12 23:19:11
update console to pass entered input directly through to navigate command.
1 parent 29a6269
Changed files (2)
bin/app.rb
lib/console.rb
@@ -1,9 +1,4 @@
-require 'plateau'
-require 'rover'
-require 'north'
-require 'east'
-require 'west'
-require 'south'
+require 'navigate_rover'
 
 class Console
   def initialize(input, output)
@@ -11,29 +6,17 @@ class Console
     @output = output
   end
   def run
-    edge = ask('enter size of terrain:', ' ')
-    terrain = Terrain.new({:x => edge[0].to_i, :y => edge[1].to_i})
+    edge = ask('enter size of terrain:')
+    landing = ask('enter landing coordinate:')
+    instructions = ask('enter instructions:')
 
-    landing = ask('enter landing coordinate:', ' ')
-    rover = terrain.deploy_rover_to(landing[2], {:x => landing[0].to_i, :y => landing[1].to_i})
-
-    ask('enter instructions:', //).each do |instruction|
-      case(instruction)
-      when 'M'
-        rover.move_forward(terrain)
-      when 'R'
-        rover.turn_right
-      when 'L'
-        rover.turn_left
-      end
-    end
-
-    @output.puts "final location: #{rover}"
+    command = NavigateRover.new(edge, landing, instructions)
+    @output.puts "final location: #{command.run}"
   end
 
-  def ask(message, split)
+  def ask(message)
     @output.puts message
     @output.print '> '
-    @input.gets.split(split)
+    @input.gets
   end
 end