DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: stuck with java excersise

  1. #1
    Join Date
    Jun 2006
    Posts
    1

    stuck with java excersise

    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.

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    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.
    Last edited by sjalle; 06-11-2006 at 06:16 PM.
    eschew obfuscation

Similar Threads

  1. Replies: 2
    Last Post: 06-14-2006, 03:16 PM
  2. Java vs. .Net. A questionnaire
    By Basil in forum .NET
    Replies: 1
    Last Post: 05-13-2005, 06:46 AM
  3. DevX does seem one sideded
    By Rob Abbe in forum Talk to the Editors
    Replies: 44
    Last Post: 01-13-2003, 03:57 PM
  4. learning c# very confusing.
    By Mike Tsakiris in forum .NET
    Replies: 11
    Last Post: 10-04-2002, 05:32 PM
  5. Re: VB vs. Visual Age for Java
    By JJ in forum Enterprise
    Replies: 1
    Last Post: 07-06-2000, 04:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center