problems with determination...

Hey there,

Im making a program that can simulate like 20.000 hands of poker to get a rough estimate what the average chance is the poker player gets something, for example a flush. The program exists of 2 classes, a card class and a cardDeck class and a test class.

Card Class:

publicclass card

{

private String face;

public String kleur;

public card(String cardFace, String cardKleur)

{

face = cardFace;

kleur = cardKleur;

}

/*public String getFace()

{

return face;

}

public String getKleur()

{

return kleur;

}*/

public String toString()

{

return kleur +" " + face;

}

}

Note that it allready has 2 methods to determine the kleur(suit) and face but i commented em for now.

cardDeck.class

import java.util.Random;

publicclass cardDeck

{

private card deck[];

privateint currentCard;

privatefinalint NUMBER_OF_CARDS = 52;

private Random randomnumber;

public String valueCardKleur;

public String faces[];

public String kleuren[];

public cardDeck()

{

String kleuren[] ={"Harten","Ruiten","Klaveren","Schoppen"};

String faces[] ={"Aas","Koning","Vrouw","Boer","Tien","Negen","Acht","Zeven","Zes","Vijf","Vier","Drie","Twee"};

deck =new card[NUMBER_OF_CARDS];

currentCard = 0;

randomnumber =new Random();

for(int i =0; i<deck.length;i++)

{

deck[i] =new card(faces[i%13], kleuren[i/13]);

}

//String valueCardKleur = kleuren[0];

}

publicvoid shuffle()

{

currentCard = 0;

for(int first = 0;first >< deck.length; first++)

{

int second = randomnumber.nextInt(NUMBER_OF_CARDS);

card temp = deck[first];

deck[first] = deck[second];

deck[second] = temp;

}

}

public card dealCard()

{

if(currentCard < deck.length)

{

return deck[currentCard++];

}

else

{

returnnull;

}

}

/*public card giveCard()

{

return deck[currentCard];

}

public String cardValueKleur()

{

return faces[0];

}*/

}

Here are also 2 commented methods I added to maybe get to the right endsolution.

cardDeckTest.java

publicclass cardDeckTest

{

publicstaticvoid main(String[] args)

{

String gedeeldeKaart ="";

String gedeeldeKaart2 ="";

String gedeeldeKaartKleur ="";

String gedeeldeKaartFace;

cardDeck myDeck =new cardDeck();

myDeck.shuffle();

for(int i=0;i <7; i++)

{

//System.out.println(myDeck.dealCard());

gedeeldeKaart = myDeck.dealCard().toString();

//gedeeldeKaart2 = myDeck.giveCard().getFace().toString();//door deze structuur kijg ik vast dubbele kaarten

//String gedeeldeKaartKleur = myDeck.dealCard().getKleur();

if(gedeeldeKaart.equals ("Schoppen"))

{

System.out.println(gedeeldeKaart +" -> -100 punten kneus");

}

else

{

System.out.println(gedeeldeKaart);

}

}

}

}

Now the problem is... I want to add 2 methods like getFace() and getKleur() to determine the suit and face of the dealt cards so i can determine what hand i have... The rest allready works (like the shuffling and dealing) but the last part is after 3 hours still unsuccesful so maybe you guys have any hints or maybe even straight solutions...

I sure hope so... Thanks in advance

[6870 byte] By [whappita] at [2007-10-2 13:56:23]
# 1
Please help me, i'l; add some dukes
whappita at 2007-7-13 12:00:33 > top of Java-index,Java Essentials,New To Java...
# 2

> Now the problem is... I want to add 2 methods like

> getFace() and getKleur() to determine the suit and

> face of the dealt cards so i can determine what hand

> i have...

If you need them why have you commented out these two methods in Card?

What you'll need is a class called Player or so who can hold a hand of cards.

Could you be more specific about your problem. Is it how to evaluate a hand of Poker?

whappita at 2007-7-13 12:00:33 > top of Java-index,Java Essentials,New To Java...
# 3

Here's an evaluation scheme for Poker someone wrote,

http://forum.java.sun.com/thread.jspa?forumID=54&threadID=683759

It's complicated but I think it can be simplified. In the above link I've posted another link to an evaluation scheme for Yatzee I wrote once. It shows the principle.

whappita at 2007-7-13 12:00:33 > top of Java-index,Java Essentials,New To Java...
# 4
> Please help me, i'l; add some dukesDukes are worthless.
annie79a at 2007-7-13 12:00:33 > top of Java-index,Java Essentials,New To Java...
# 5
Yes i want the program to: Deal 7 cards (texas hold em) and evaluate the hands it deals. For that i need to know what color and suit the string is. Thats what the getKleur and getFace should do...
whappita at 2007-7-13 12:00:33 > top of Java-index,Java Essentials,New To Java...
# 6

> Yes i want the program to: Deal 7 cards (texas hold

> em) and evaluate the hands it deals. For that i need

> to know what color and suit the string is. Thats what

> the getKleur and getFace should do...

Yes and that's what those methods in your Card class do. What's your problem? You have commented the methods out. Don't you know how to comment them in again?

whappita at 2007-7-13 12:00:33 > top of Java-index,Java Essentials,New To Java...