Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Video Player
00:00
00:00
00:00
- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
Use pseudocode to help lay out the memory game's code.
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
To start off,
let's think through our game and
0:00
write out some pseudocode and comments.
0:03
Pop over into cards.py.
0:06
Our card class, will hold a card
which will be a short word.
0:09
We'll also need to know if this
card has been matched or not.
0:20
So we can check to find which
cards still need to be matched and
0:24
to see if the game has been won.
0:28
Since you lay out the cards in a grid,
we'll also need to store a location so
0:36
we can find the cards
the player wants to flip over.
0:41
Lastly, we'll need to be able
to see if two cards are equal so
0:47
we can say they are matching.
0:51
We can also add the ability to print
out the card for the player as well.
0:58
The game class is going
to be a bit bigger.
1:07
We'll need to know how
big the game grid is,
1:13
a list of card options,
1:20
the columns for the top row of the grid.
1:26
and a list of all
the locations in our grid,
1:30
Then we'll need some methods.
1:35
One to create our card instances
with words paired with locations.
1:41
Another to create our grid.
1:47
Then we'll need to check for matches,
1:51
check if the game has been won,
1:57
and finally, one to run the game.
2:01
Finally, we'll need to add a dunder main,
2:05
create an instance, and
2:12
call the start game method.
2:18
Okay, now that everything is planned out,
it's time to dig in.
2:23
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