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
Start a free Courses trial
to watch this video
Use pseudocode to help layout the memory game's code.
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 up