Closed scott-steadman closed 10 years ago
You may want to make the attributes read-only. Reason: To prevent accidental modification of the attributes.
Example code:
attr_reader :player1, :player2, :deck, :crib
def initialize
@deck = Deck.new
@player1 = Player.new
@player2 = Player.new
@crib = []
end
in start_round method have players draw from deck. Reason: improve readability, and get rid of temporary variable.
Example code:
def start_round
6.times do
player1.draw_from(deck)
player2.draw_from(deck)
end
end
Great idea. I can't wait to do all of this Friday night. Maybe have a look again on Sunday night?
Sure! I'll watch the repo so I know when you've pushed your changes.
Have score method return a string. Reason: you may not want to write the score to stdout.
Example code:
def score
["Player1 Score: #{player1.score}", "Player2 Score: #{player2.score}"].join("\n")
end
Another option would be to have score take a destination as a parameter. Reason: you can tell the method where to write the output, and let it handle formatting...
def write_score(io=STDOUT)
io.puts "Player1 Score: #{player1.score}"
io.puts "Player2 Score: #{player2.score}"
end
I haven't played cribbage in a while, so take my comments lightly.