Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

halkazi

OldMaidGame : Why am I unable to add a card to a hand?

  • one year ago
  • one year ago

  • This Question is Open
  1. halkazi
    Best Response
    You've already chosen the best response.
    Medals 1

    Program file attached.

    • one year ago
    1 Attachment
  2. rsmith6559
    Best Response
    You've already chosen the best response.
    Medals 0

    Print the value of card in the method to make sure that it's what you expect.

    • one year ago
  3. halkazi
    Best Response
    You've already chosen the best response.
    Medals 1

    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.

    • one year ago
  4. jcole
    Best Response
    You've already chosen the best response.
    Medals 0

    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 <module> 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.

    • one year ago
  5. halkazi
    Best Response
    You've already chosen the best response.
    Medals 1

    Thanks. Could you attach your file, so that I can follow it better?

    • one year ago
  6. halkazi
    Best Response
    You've already chosen the best response.
    Medals 1

    Here's my new program, and it still does not add cards to the hands. The remove card from deck works though.

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.