Click to See Complete Forum and Search --> : stuck with java excersise


vampiros
06-10-2006, 05:13 PM
hi, i wonder if anyone could please help me with a problem im having with my java excersise. its for a card game. the game is played by shuffling cards and placing them face down in a 4 by 4 patern. the game is complete when all the cards are face up.
iv already created the card class, which contains the atributes for the images on both sides of the card, the value of the card. the main operation of this being flip () which turns the card over visually. this class is derived from the JComponent.
the pack class having the main operations shuffle() and dealCard().
the game class is derived from JFrame.
iv created some of the code for the cardHander class but iv become so lost.
the logic is:
IF
state =0:
Flip card clicked
Disable card reclicking
move to state 1
state=1:
Flip card clicked
Disable card reclicking
move to state 2
IF this was the final card to be turned over THEN
set cardsremaining to zero
ENDIF
state=2:
IF last two cards turned over are the same THEN
reduce cardsremaining by 2
ELSE
turn both cards face down again
re-enable both cards for clicking
Flip card clicked
Disable card reclicking
Move state to 1
ENDIF
reduce score by 1
change displayed score
IF
no cards left
set state to 3
score = 0:
set state = 4
ENDIF
IF
state = 3:
IF this is a new high score THEN
get players name
add details to top ten list
save the top ten to a file
ENDIF
display top ten scores
state = 4:
quit game
ENDIF

i know its a bit much, but all i need left to do with my excersise is to translate this logic into java code. if anyone could help me or provide me with a link to similar examples for a card game, id very much appreciate it.
thank you.

sjalle
06-11-2006, 06:10 PM
but all i need left to do with my excersise is to translate this logic into java code
that's the objective of your excersise .. I don't have any relevant links, but if you want assistance in this forum, you should supply some initial code effort at least.