Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Basic Object-Oriented Python!
You have completed Basic Object-Oriented Python!
Preview
Create the logic for the card class for our memory game.
Accomplished in this Video
- Created a Card class
- Gave it two instance attributes that are passed in - the word for the card and its location
- Added another instance attribute that is not passed in - matched
- Created 2 dunder methods
-
__eq__= check if two cards are equal -
__str__= print out the word for a card
-
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
In the init method,
it'll take two arguments.
0:02
One will be the word each card will
hold and the second, its location.
0:09
Inside of the method,
we'll need to set the card attribute and
0:16
the location attribute.
0:19
Then create a matched attribute
that is set to false, so
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up