-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cara & Emilce -- Scrabble -- Octos #15
base: master
Are you sure you want to change the base?
Conversation
ScrabbleWhat We're Looking For
|
@tile_bag = BAG.each_with_object([]) { |(letter, value),tile_bag| | ||
#iterate through the letters val times and shovel the | ||
#letter to the individual letter tilebag | ||
value.times { (tile_bag << letter.to_s)}} # |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small indentation error. The above loops also look awkward. They are however an awesome way to turn the hash above into an array.
class Scoring | ||
SCORING_RUBRIK = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good use of a constant, and a good choice of data structure!
|
||
elsif score == highest_score | ||
# highest_word = | ||
self.break_tie(highest_word, word) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, a helper method!
end | ||
|
||
def self.break_tie(incumbent, challenger) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done here
end | ||
|
||
it 'returns the highest word if there are two words' do | ||
words = [] | ||
words.push("zebra", "otter") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest also varying the order of the words since that makes a difference in a tie.
# return @words_played | ||
end | ||
|
||
def play(word) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem here, even if I've won it pushes the new word into @words_played
end | ||
|
||
def total_score() | ||
word_scores = @words_played.map do |word| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good practice with .map
and .inject
end | ||
|
||
def highest_word_score | ||
highest_word = Scrabble::Scoring.highest_score_from(@words_played) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you just use the highest_scoring_word
here?
|
||
end | ||
|
||
it "returns score of a play/word " do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about a test for what happens if you keep playing after you won?
value.times { (tile_bag << letter.to_s)}} # | ||
end | ||
|
||
puts "#{@tile_bag}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
puts is unneeded here:
Scrabble
Congratulations! You're submitting your assignment.
Comprehension Questions
score
method in theScoring
class a class method instead of an instance method?Enumerable
mixin? If so, where and why was it helpful?