Donnerstag, 13. November 2008

EE3206 Java-whichCard()

EE3206/EE5805 Java Hearts Programming Project

before executing westPlayer.playACard(CArd dealCard);, CPU needs to determine which card to deal, hence the algorithm :

public Card whichCardToDeal(int currentSuit);


public Card whichCardToDeal(int currentSuit)
{
if (player can follow suit)
{
retrun card same with the current suit
}
else if (player leads the suit && heartBreak == false)
{
if (player can deal card other than HEART)
{
retrun a card which is NOT a HEART
}
else
{
this player can only deal HEARTS
deal a HEART
heartBreak = ture
}
else if (player leads the trick && heartBreak == true)
{
can deal any card
}
else
{
this player only follow suit
return any card
}

}





Keine Kommentare: