|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectm3g10.CardDeck
public class CardDeck
Manages cards in a deck.
Card| Field Summary | |
|---|---|
private java.util.Vector |
cards
The cards. |
private Card |
currentCard
Currently selected card. |
private int |
state
Current game state. |
private static int |
STATE_LOST
State LOST. |
private static int |
STATE_MATCH
State MATCH. |
private static int |
STATE_NO_MATCH
State NO_MATCH. |
private static int |
STATE_ONE_CARD
State ONE_CARD. |
private static int |
STATE_START
State START. |
private static int |
STATE_WON
State WON. |
| Constructor Summary | |
|---|---|
CardDeck()
|
|
| Method Summary | |
|---|---|
void |
add(Card card)
Adds a card to the deck. |
boolean |
allCardsMatched()
Checks whether all cards were matched. |
void |
closeAll()
Closes all cards except for cards that were successfully matched. |
private Card |
findCard(int keyCode)
Finds the card with the given key code. |
Card |
getCurrentCard()
Getter for current card. |
int |
getNumberOfCards()
Getter for number of cards. |
boolean |
hasLost()
Returns true if player has lost. |
boolean |
hasWon()
Returns true if player has won. |
private void |
init()
Initializes cards by closing them and setting the match flag to false. |
void |
process(int keyCode)
Main loop which advances the game state. |
private void |
shuffle()
Assigns cards a random place and closes them. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private java.util.Vector cards
private Card currentCard
private static final int STATE_START
private static final int STATE_ONE_CARD
private static final int STATE_MATCH
private static final int STATE_NO_MATCH
private static final int STATE_LOST
private static final int STATE_WON
private int state
| Constructor Detail |
|---|
public CardDeck()
| Method Detail |
|---|
public void add(Card card)
card - new card.public void process(int keyCode)
keyCode - selected key code.private void shuffle()
private void init()
public void closeAll()
public boolean allCardsMatched()
private Card findCard(int keyCode)
keyCode - key code to match.
public int getNumberOfCards()
public Card getCurrentCard()
public boolean hasWon()
public boolean hasLost()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||