Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+9 votes

In the memory game I am trying to call containsPoint from my card class. I am using a point from getMouse, but I get an error saying that I am missing the required positional argument point. How can I fix this?

asked in CSC201 by (8 points)

1 Answer

+2 votes

First, I didn't need to call the containsPoint method from memory_game.py. When the user clicks in the window, you need to know whether the user clicked in a card or not, and if the user clicked in the card, which card was clicked. That information more directly comes from the getCardAtPoint method of the Board class. Notice that getCardAtPoint in the Board class calls containsPoint from the card class.

If you are calling containsPoint from the card class in memory_game.py, then before the dot needs to be an object of type Card. The parameter to containsPoint needs to be of type Point.

So if card is of type Card, then
click = window.getMouse() # click is of type Point and window is your GraphWin object
if card.containsPoint(click): # this would be a correct way to call containsPoint method

answered by (8 points)
...