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

