From ccbc65bd01a9c460539e936cfbc5eba8f97c0104 Mon Sep 17 00:00:00 2001 From: mo k Date: Sun, 12 Feb 2012 14:19:44 -0700 Subject: move forward when facing east or west. --- lib/rover.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib') diff --git a/lib/rover.rb b/lib/rover.rb index 35ab1f9..90d7757 100644 --- a/lib/rover.rb +++ b/lib/rover.rb @@ -42,6 +42,9 @@ class East def turn_left North.new end + def forward(current_location) + current_location[:x] = current_location[:x]+1 + end end class West def direction @@ -53,6 +56,9 @@ class West def turn_left South.new end + def forward(current_location) + current_location[:x] = current_location[:x]-1 + end end class South def direction -- cgit v1.2.3