Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Memory Card Game  RSS feed

 
giorgos andreou
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I have a university assignment and I have problems at figuring out which classes are necessary to Create for the first part that I only have to create the classes and their methods without any further code.

This is the topic:
The basic game contains 2 copies of 26 different images that we place in a field( 4 lines, 13 columns). The game can be played by a player(count his steps-opening pairs) or by a team (when someone find a pair he playes again). Now we have some variatios :
1) Someone who found a pair doesn't play again, but continues the next one (team game only).
2)Double game (2 copies of 52 different images) in field( 8 x 13).
3)Trio-quartet, we have 3/4 copies in 26 different images.
4) We place the cards in random ( no field).
5)Someone in team game decides not to play.
6)When we open a pair, the cards change places.
7)The pairs,trio,quartet are opened in order, a number is written at the image.
8)Battle, only two players who play in two fields(4 x 13), one for each one. Each field contains 52 different pictures -like double game. Each player can open cards only from his field. One of them begin opening a card and the other one responds . If the two cards are similar, the second one wins the pair. Then the first player is changed.

Finally, when we have more than one player, one of them can be controlled by computer with 3 memory levels( a(goldfish)-> remember nothing, b(kangaroo)-> remember the half, c(elephant) -> remember everything )
 
Knute Snortum
Sheriff
Posts: 4081
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Since this is an assignment, post a few of the classes you think you need and we'll nudge you in the right direction. In general, the classes should be the "nouns" in your assignment.

 
giorgos andreou
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some of the classes I think I should use are:
One class for the Card, one class for the Board(Parent) and maybe two child classes for the GridBoard and the RandomBoard,
a Game class that maybe can identify whether the cards are match together, whether to turn a card and when the Game ends, a Player(Parent) class and two child classes for the HumanUser and the CPU. Then I'm thinking of making different classes for each game mode of the Memory Game(for example Basic, Trio/Quartet, DoubleBoard and Duel(Battle)) but I'm not so sure(I think that maybe some of them can be created as methods inside other classes or that they can be inside one class altogether).
Also there are the other variations of the Game Modes(CardsInOrder, Each PLayer plays only once, cards switch together if you choose wrong and the variation that lets the player decide if he wants to turn another card) as you can see at the topic and I can't either decide about how many classes to make of these or if they are methods.
Also I cannot exactly understand if I have to use Single and Multi Player classes.

Thank you very much for assisting me!
 
Knute Snortum
Sheriff
Posts: 4081
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then I'm thinking of making different classes for each game mode of the Memory Game(for example Basic, Trio/Quartet, DoubleBoard and Duel(Battle)) but I'm not so sure(I think that maybe some of them can be created as methods inside other classes or that they can be inside one class altogether).

Think about what a Game class would do. Can you abstract (find common) functions to a Game class from the specific games? If so, Game should be an interface or abstract class.
Also there are the other variations of the Game Modes(CardsInOrder, Each PLayer plays only once, cards switch together if you choose wrong and the variation that lets the player decide if he wants to turn another card) as you can see at the topic and I can't either decide about how many classes to make of these or if they are methods.

You wouldn't want to write a class with just one method, but then again, it wouldn't be the end of the world! Deciding what is a method and what is a class can be difficult, but think of it this way: a method should do one thing, only one thing, and do it well. Methods are "verbs" in this sense. Classes are nouns. So Game is a class and endGame() is a method. Make sense?
 
giorgos andreou
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You think that I should put the turn() and match() method for the cards and the methods startGame() and endGame() at my abstract Game class that can be Inherited by all the other game modes classes or in the Board class like the post you've already seen for this assingnment?
 
Knute Snortum
Sheriff
Posts: 4081
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"match", as in match a card? Is would think this would be matchCards(), which would give you a hint about what parameters it will need. "turn" as in takeATurn(), or loseTurn()? See how naming a method correctly shows how you should design the project.
 
giorgos andreou
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By turn() I mean flipCards(), sorry I stated it wrong and by match() I mean matchCards().
Can you help me decide in which class I should put them?
 
Knute Snortum
Sheriff
Posts: 4081
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the "thing" that's flipping cards and matching cards? I would think Game but I'm open to other suggestions.
 
Liutauras Vilda
Marshal
Posts: 4657
319
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reading instructions again and again is quite powerful. At that time you read it might mean nothing, later you have to do it again.
giorgos andreou wrote:The game can be played by a player(count his steps-opening pairs) or by a team (when someone find a pair he playes again).
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
giorgos andreou wrote:Hello, I have a university assignment and I have problems at figuring out which classes are necessary to Create for the first part that I only have to create the classes and their methods without any further code...

I suspect that someone from your class may have beaten you to it. You may find some info there worth reading.

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!