| | |
Java Project Help...
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2009
Posts: 4
Reputation:
Solved Threads: 0
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 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.
•
•
Join Date: Mar 2009
Posts: 4
Reputation:
Solved Threads: 0
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:
Card
Deck
Game
Hand
(Thats a guess, but im not 100% sure, its just about what kind of methods each one would have... :s )
Card
Deck
Game
Hand
(Thats a guess, but im not 100% sure, its just about what kind of methods each one would have... :s )
•
•
Join Date: Apr 2008
Posts: 977
Reputation:
Solved Threads: 145
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).
•
•
Join Date: Jan 2008
Posts: 3,828
Reputation:
Solved Threads: 501
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:
http://www.daniweb.com/code/snippet1019.html
http://www.daniweb.com/code/snippet1034.html
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.
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:
http://www.daniweb.com/code/snippet1019.html
http://www.daniweb.com/code/snippet1034.html
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.
It took about 0.003169118 seconds to shuffle.
java Syntax (Toggle Plain Text)
public void shuffle(){ for(int i=0;i<1000;i++){ int rand = (int)(Math.random()*50)+1; deck.add(deck.remove(rand)); } }
It took about 0.003169118 seconds to shuffle.
Last edited by jasimp; Mar 14th, 2009 at 3:32 pm.
"Argyou not with the hand you are dealt in cards or life." ---- Wizard and Glass
•
•
Join Date: Mar 2009
Posts: 4
Reputation:
Solved Threads: 0
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...
http://rapidshare.com/files/209260005/pontoon.rar
Thanks in advance
1
http://rapidshare.com/files/209260005/pontoon.rar
Thanks in advance
1
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.
Last edited by jasimp; Mar 14th, 2009 at 6:13 pm.
"Argyou not with the hand you are dealt in cards or life." ---- Wizard and Glass
•
•
Join Date: Mar 2009
Posts: 4
Reputation:
Solved Threads: 0
This is the line im getting my error in:
and the error says "cannot find symbol - class card"
Thanks...
Java Syntax (Toggle Plain Text)
private ArrayList<Card> card = new ArrayList<card>();
and the error says "cannot find symbol - class card"
Thanks...
•
•
Join Date: Jan 2008
Posts: 3,828
Reputation:
Solved Threads: 501
Java Syntax (Toggle Plain Text)
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')); else if(i < 26) card.add(new Card(i%13+1, 'H')); else if(i < 39) card.add(new Card(i%13+1, 'D')); else card.add(new Card(i%13+1, 'C')); } } public void shuffle() { Collection.shuffle(card); } public Card pickNextCard() { return card.remove(0); } }
Java Syntax (Toggle Plain Text)
class Card { private int rank; private char suit; public int getRank() { return(rank); } public int getSuit() { return(suit); } public Card(int r, char s) { rank = r; suit = s; } public boolean equals(Card otherCard) { if((rank == otherCard.rank) && (suit == otherCard.suit)) return(true); else return(false); } }
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.
[Edit]
Note: Java is case sensitive:
private ArrayList<Card> card = new ArrayList<card>();Red above should be capitalized.
[/Edit]
Last edited by VernonDozier; Mar 14th, 2009 at 6:59 pm.
![]() |
Similar Threads
- Hello! Team working on a java project for university (Java)
- [HOMEWORK] Need help with java project (Java)
- java project (Java)
- Java project (Java)
- java project database error (Java)
- Java Freelancer (Post your Resume)
- engg. java project (Java)
- Java project ideas (Java)
Other Threads in the Java Forum
- Previous Thread: How to find local systems free space?
- Next Thread: what's wrong?
| Thread Tools | Search this Thread |
-xlint android api applet application array arrays automation bi binary blackberry block bluetooth chat class classes client code compile compiler component database developmenthelp eclipse error event exception fractal freeze game gameprogramming givemetehcodez graphics gui health html ide image input integer j2me j2seprojects java javac javaprojects jetbrains jni jpanel jtable julia learningresources lego linux list login loop loops mac map method methods mobile netbeans newbie notdisplaying number online oracle page print problem program programming project qt recursion scanner screen server set singleton size sms sort sql string swing system template textfields threads time title tree tutorial-sample update variablebinding windows working xor






