- #1
Sthiel
- 6
- 0
So I'm working on a simple memory game nonGUI: Write a program that plays the memory matching game. When it start, the program prompts the user for the number of rows and columns for the game board that contains the cards. The total number of cards must be even. Assume that the board dimensions are at most 8 by 9 or 9 by 8. You cards must be numbered from 1 through (number of rows * number of columns) / 2. Your program allows the player to specify the cards that she would like to select through a coordinate system as shown in the sample run below. All the cards that are face down are indicated by *
So far I am making 3 classes. Card, Deck and Game. Card will be used to store both the card's value and face (up or down). Deck to contain the cards needed. Its methods include a mthod to deal a card, another for shuffling the deck, and a method that returns number of cards left in the deck. The class Game simulates playing a single game and represents the interaction between the user and the other classes. Its instance members store a 2D list (of card objects) representing the game board where the cards are placed, number of rows and number of columns of the game board. Among the instance methods of the Game class: play(), which simulates playing the game; isGameOver(), which checks whether or not the game is over; displayBoard(), which displays the board; populateBoard(), which creates the initial 2D list of identical pairs of cards with all the cards facing down.
So the first question I have is regarding the deck class. I was going to create a dictionary for the cards but I am not sure if I would need to include all the possible card values or I am assuming there is an easier way of writing that.
Any input on this first question or any input really would be appreciated. And I will probably have more questions as I go along. Thank you
So far I am making 3 classes. Card, Deck and Game. Card will be used to store both the card's value and face (up or down). Deck to contain the cards needed. Its methods include a mthod to deal a card, another for shuffling the deck, and a method that returns number of cards left in the deck. The class Game simulates playing a single game and represents the interaction between the user and the other classes. Its instance members store a 2D list (of card objects) representing the game board where the cards are placed, number of rows and number of columns of the game board. Among the instance methods of the Game class: play(), which simulates playing the game; isGameOver(), which checks whether or not the game is over; displayBoard(), which displays the board; populateBoard(), which creates the initial 2D list of identical pairs of cards with all the cards facing down.
So the first question I have is regarding the deck class. I was going to create a dictionary for the cards but I am not sure if I would need to include all the possible card values or I am assuming there is an easier way of writing that.
Any input on this first question or any input really would be appreciated. And I will probably have more questions as I go along. Thank you