Hi everyone, id firstly like to start off by saying i am new here and if i make any mistakes in anyway i am sorry in advance...

I was wondering if anyone could "HELP" me complete a project that i am doing, i basically have to create the card game (21 - Blackjack/Pontoon)

And need abit of help as in where to start...What ill need in terms of classes, methods in classes etc... Im not asking anyone to do it for me i no that for those who start saying im asking people to do it for me (which i dont) i just need some advice on where to make a start and how to make a start. If anyone is interested in helping me could you please send me a pm and i can send you the rules of the game that i need to implement into the code...

Thank you all for taking your time to read this thread.
Have a nice day

The 1.

p.s. hope to hear from people soon, remember if you do wish to help me i will forward the poject rules to you (dont wanna waste other peoples time by posting it all here) Thanks.

I was told to make UML diagrams firstly, as that would help, but im stuck on that to like what types of method would each class need. The classes i think this project would need are:


(Thats a guess, but im not 100% sure, its just about what kind of methods each one would have... :s )

Sorry, don't have the time to do much on this, but start with a Card class (52 instances!) and a Player class (that holds a list of the Cards that the player holds, the player's current cash and bet, and has the logic for stick/twist etc). Maybe a Dealer class that has the logic to "deal" Cards to Players and perform it's own versions of the stick/twist logic, and compute payouts (subclass Player to avoid duplication).

Normally the idea on this forum is to not do things via PM since the goal is to make everything public, so you'll probably get a better response if you post the rules of the game on the thread.

I imagine you'll need a function to shuffle cards though, probably a function in the Deck class. I have a couple of code snippets in the C++ section dealing with that:


The first one is probably useless for Java since it involves pointers, but the second may come in handy and could be transformed into Java fairly easily.

When I programmed Blackjack I used an ArrayList to hold all my cards. To shuffle I simply had a for loop run about 1000 times, randomly picking a number 0-51, removing the object at that spot while at the same time adding it to the end. Just another idea for a shuffle 'algorithm'. I wouldn't use this with a lot of elements but with 52 it works well.

public void shuffle(){
for(int i=0;i<1000;i++){
	int rand = (int)(Math.random()*50)+1;

It took about 0.003169118 seconds to shuffle.

Iv uploaded the code so far on rapidshare if you could just download it and check it out that would be greatly appreciated, it dont seem to compile...

You need to post the section of code that is giving you trouble here, not the whole thing, only where you are getting an error (don't forget to tell us what error/exception you are getting.) A great skill to have is the ability to go through your code and figure out why "it don't seem to compile", if you ask for help every time the answer doesn't dance around naked in front of your face, you'll never develop that skill.

I like the way you say this, straight to the face

This is the line im getting my error in:

private ArrayList<Card> card = new ArrayList<card>();

and the error says "cannot find symbol - class card"


import java.util.*;
import java.util.Collection.*;

class DeckOfCards
    private ArrayList<Card> card = new ArrayList<card>();
    public DeckOfCards()
        for(int i=0; i < 52; i++)
            if(i < 13)
                card.add(new Card(i%13+1,'S'));
                if(i < 26)
                card.add(new Card(i%13+1, 'H'));
                if(i < 39)
                card.add(new Card(i%13+1, 'D'));
            card.add(new Card(i%13+1, 'C'));
    public void shuffle()
    public Card pickNextCard()
        return card.remove(0);
class Card
    private int rank;
    private char suit;
    public int getRank()
    public int getSuit()
    public Card(int r, char s)
        rank = r;
        suit = s;
    public boolean equals(Card otherCard)
        if((rank == otherCard.rank) && (suit == otherCard.suit))

Since these are in separate files, try putting the word "public" at the top next to the name of the class. I would think that you would get some other errors besides just the one you listed, but stick the word "public" in front of the word "class" in your java files and see if the errors go away.

Note: Java is case sensitive:

private ArrayList<Card> card = new ArrayList<card>();

Red above should be capitalized.

This article has been dead for over six months. Start a new discussion instead.