[Power of Thor] Create methods for each direction and refactor the find direction method#6
Open
Slavunderkind wants to merge 2 commits intomasterfrom
Open
[Power of Thor] Create methods for each direction and refactor the find direction method#6Slavunderkind wants to merge 2 commits intomasterfrom
Slavunderkind wants to merge 2 commits intomasterfrom
Conversation
b8e5d88 to
73f6435
Compare
9ba0df4 to
ca817fb
Compare
Training/Easy/power_of_thor.rb
Outdated
| @@ -7,58 +7,52 @@ def initialize | |||
| @light_x, @light_y, @x, @y = gets.split(' ').collect(&:to_i) | |||
Collaborator
There was a problem hiding this comment.
Don't call gets here. Instead, call it from outside the object and give it to an argument to the initialize method
Training/Easy/power_of_thor.rb
Outdated
| loop do | ||
| remaining_turns = gets.to_i # The remaining amount of turns Thor can move. Do not remove this line. | ||
| puts find_direction | ||
| find_direction |
Collaborator
There was a problem hiding this comment.
find_direction does something else than just finding a direction
Training/Easy/power_of_thor.rb
Outdated
| def move_north | ||
| self.y -= 1 | ||
| if x == light_x | ||
| puts 'N' |
Collaborator
There was a problem hiding this comment.
Take the puts statements out of all of the move_ methods - make the methods return the string value, and then use puts inside the loop. The reason is that if you change the way you output (in this case, puts), you will have to refactor all of the move_ methods, as opposed to just changing it in one place.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#5