anonymous
  • anonymous
OldMaidGame : Why am I unable to add a card to a hand?
Classes
katieb
  • katieb
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

anonymous
  • anonymous
Program file attached.
1 Attachment
rsmith6559
  • rsmith6559
Print the value of card in the method to make sure that it's what you expect.
anonymous
  • anonymous
I am not sure I understood. I am printing the value of the card, and it is the top card in the deck, but the addCard method is giving an error.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
The addCard method isn't giving you an error. I tried running the code you attached, the exception says: Traceback (most recent call last): File "C:/Users/joshua/Documents/MIT/test.py", line 182, in game.play(["Allen","Jeff","Chris"]) File "C:/Users/joshua/Documents/MIT/test.py", line 144, in play self.deck.deal([names],51) File "C:/Users/joshua/Documents/MIT/test.py", line 63, in deal hand.addCard(card) AttributeError: 'list' object has no attribute 'addCard' Note the last line where it says that 'list' object has no attribute addCard? That tells us that hand is a list and not a Hand or Deck object. In the lines above this we see that this happened in the self.deck.deal method. You can see the actual call here: File "C:/Users/joshua/Documents/MIT/test.py", line 144, in play self.deck.deal([names],51) Note that you are wrapping the list of names you passed in within a list. Then that list is being passed into the function. I'm pretty sure you meant to pass in self.hands. Moreover, you are going to need to call the method to remove cards rather then operating on cards itself when you run into the next error.
anonymous
  • anonymous
Thanks. Could you attach your file, so that I can follow it better?
anonymous
  • anonymous
Here's my new program, and it still does not add cards to the hands. The remove card from deck works though.

Looking for something else?

Not the answer you are looking for? Search for more explanations.