-
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
Brittany and Maddie #25
base: master
Are you sure you want to change the base?
Conversation
ScrabbleWhat We're Looking For
|
# associated with the key and put that in an array of integers | ||
|
||
|
||
if !character_check.include?(character) || letters.length == 0 || letters.length > 7 |
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.
This if
doesn't need to be in the loop, at least the checks for the length of the array.
return nil | ||
|
||
else | ||
values_of_letters << LETTER_VALUES.fetch(character) |
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.
Instead of using fetch
you could just
values_of_letters << LETTER_VALUES[character]
end | ||
|
||
it 'if tied, prefer a word with 7 letters' do | ||
array_of_words = ["ww", "bananas"] | ||
Scrabble::Scoring.highest_score_from(array_of_words).must_equal("bananas") |
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.
It's also important to vary the order here, just in case order played a role.
end | ||
|
||
it 'if tied and no word has 7 letters, prefers the word with fewer letters' do | ||
array_of_words = ["x", "brasas"] | ||
Scrabble::Scoring.highest_score_from(array_of_words).must_equal("x") |
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.
Same as above
|
||
def winner | ||
return @total_score > 100 | ||
end |
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.
Fix your indentation!
Also this method should be named: won?
end | ||
end | ||
|
||
|
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.
highest_word_score
???
highest_scoring_word
????
end | ||
|
||
def play(word) | ||
if winner == false |
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.
This method is supposed to return the score of the word played, or false if the player has already won.
|
||
# Creating an instance of letter quantity to be used though class tilebag. | ||
def initialize | ||
@default_set = {A:9, B:2, C:2, D:4, E:12, F:2, G:3, H:2, I:9, J:1, K:1, L:4, M:2, N:6, O:8, P:2, Q:1, R:6, S:4, T:6, U:4, V:2, W:2, X:1, Y:2, Z:1} |
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.
There's a problem with this structure. It gives each letter an equal chance of being drawn despite the fact that there are 2 "M" tiles and 9 "A" tiles. Uh oh!
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?