Computer Science Canada

Need help with cards and war

Author:  BlAcK TuRtLe [ 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);
        }
    }


Author:  Tony [ Sun Nov 23, 2003 6:35 pm ]
Post 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.

Author:  BlAcK TuRtLe [ Sun Nov 23, 2003 7:17 pm ]
Post 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.


: