-
Notifications
You must be signed in to change notification settings - Fork 45
BlackJack Assignment submission. #40
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
base: master
Are you sure you want to change the base?
Conversation
Initial code looks fine, no issues there.
I think it should return data; if you want to have a method, or a class, that formats it nicely, I think that's a good addition to the project. |
@jwo Okay. Will add that to the wishlist. |
Try on the player-hand.. if it's over 21 and hits, that's an exception and it shouldn't grab a card. |
@jwo I did this:
I only got this far for the test case as I do not understand how you to make method call on a mock object which will change the properties thereof.
|
Use a real Game object, with a mock card object. At some point, the objects must be real. |
@jwo Understood. However, the Game object comes with a randomised Deck object which I cannot change/set to suit this specific scenario? |
although that's the idea, set the game's deck to something where you have the cards predetermined. On Tue, Feb 25, 2014 at 10:16 AM, drammopo [email protected]
|
@jwo There's no setter method - only |
With the following class: class Deck
attr_reader :cards
def initialize
@cards = 1..52 #build cards
end
end You could do: describe Deck do
it "has cards" do
the_cards = [double, double]
deck = Deck.new
deck.stub(:cards) { the_cards}
expect(deck.cards).to eq(the_cards)
end
end So, you're stubbing the This only works if you are diligent in only using |
(then you would pass in your Deck to Game, and you know what happens) |
@jwo After changing the Card's to_s to show "QH" instead of queen-hearts"....
Should we change the Game#status to make
@player_hand.cards
and@delaer_hand.cards
more readable?