Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Need help with cards and war
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
BlAcK TuRtLe




PostPosted: Sun Nov 23, 2003 6:27 pm   Post subject: Need help with cards and war

im making a card game (war) for school. It uses funtions to give randomly generated cards. However i can't figure out how to make it so that after a crad is picked it cant be picked again. Any help?
Heres the code for the main program.
code:

// The "WAR" class.
import java.awt.*;
import hsa.Console;
import Suits;
import Routine6;
public class WAR
{
    static Console c;           // The output console
    static Suits d;
    static Function2 e;
    public static void main (String [] args)
    {
        c = new Console ();
        d = new Suits (c);
        e = new Function2 (c);
        String suit1, suit2, card1, card2;
        Color color = new Color (115, 44, 13);
        c.setColor (color);
        c.fillArc (0, 180, 640, 540, 0, 180);
        c.setColor (Color.blue);
        c.fillRect (10, 10, 130, 170);
        c.fillRect (500, 10, 130, 170);
        c.setColor (Color.white);
        c.fillRect (120, 250, 130, 170);
        c.fillRect (400, 250, 130, 170);
        //for (int count = 0 ; count <= 26 ; count++)
        //{
        suit1 = e.suit ();
        suit2 = e.suit ();
        card1 = e.card ();
        card2 = e.card ();
        if (suit1 == "Clubs")
        {
            d.club (125, 270);
            d.club (200, 385);
        }
        else if (suit1 == "Diamonds")
        {
            d.diamond (140, 265);
            d.diamond (220, 375);
        }

        else if (suit1 == "Hearts")
        {
            d.heart (130, 250);
            d.heart (217, 380);
        }
        else if (suit1 == "Spades")
        {
            d.spade (130, 265);
            d.spade (220, 380);
        }
    }

Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun Nov 23, 2003 6:35 pm   Post subject: (No subject)

there's a code writen to generate a random number list. here though its in turing, but that shouldn't matter. You'll get the idea.

You would basically use that to "shuffle" your card deck and then instead of randomly picking a new card, you just grab the next one available from the shuffled deck.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
BlAcK TuRtLe




PostPosted: Sun Nov 23, 2003 7:17 pm   Post subject: (No subject)

Well, our class hasnt covered arrays yet. I think i have an idea of what to do ill reply later after i work on it for a while. Thanks for the help tho.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: