BlackJack Help
import java.util.*;
publicclass blackjack
{
privatestaticfinalint DEFAULTROUNDS = 7;
publicstaticvoid main(String[] args)
{
String titlestring ="Blackjack Game by Ali Syed";
//your code.
System.out.println(titlestring);
}
}
class Card
{
//Static constants
publicstaticfinalint CLUB = 0;
publicstaticfinalint DIAMOND = 1;
publicstaticfinalint HEART = 2;
publicstaticfinalint SPADE = 3;
//Member fields
privateint suit;//CLUB through SPADE
privateint rank;//2 through 14; 11-14 are J,Q,K,A
//Constructors
public Card(int irank,int isuit){rank = irank; suit = isuit;}
public Card(){rank = 2; suit = CLUB;}
//Accessors
publicint value()
{
}
publicboolean isAce(){return rank >= 14;}
public String toString()
{
String rankstring, suitstring;
if (rank < 11)
rankstring ="" + rank;
elseif (rank == 11)
rankstring ="J";
elseif (rank == 12)
rankstring ="Q";
elseif (rank == 13)
rankstring ="K";
else//rank == 14
rankstring ="A";
if (suit == CLUB)
suitstring ="\u0005";/* Instead of "Club", we use a special
symbol that we specify with a four hex digit unicode escape.
We use similar codes fo the other suits. */
elseif (suit == DIAMOND)
suitstring ="\u0004";
elseif (suit == HEART)
suitstring ="\u0003";
else// (suit == SPADE)
suitstring ="\u0006";
return rankstring + suitstring;
}
}
class Hand
{
//Static constants
privatestaticfinalint MAXCOUNT = 20;//Just to be safe we allow large hands.
//Member fields
private Card cards[] =new Card[MAXCOUNT];
privateint count = 0;
int numberofsoftaces = 0;//this is a helper variable that is set by total().
//Constructor
public Hand(){}
//Mutators
publicvoid add(Card crd){cards[count] = crd; count++;}
//Accessors
publicint total()
{
int sum = 0;
numberofsoftaces = 0;//Reset the helper variable.
for (int i=0; i<count; i++)
{
sum += cards[i].value();
if (cards[i].isAce())
numberofsoftaces++;
}
if (sum > 21)
while (numberofsoftaces > 0)
{
sum -= 10;
numberofsoftaces--;
}
return sum;
}
publicboolean soft()// Returns true if you have an ace counted as 11 rather than 1
{
total();//Call this to set numberofsoftaces;
return (numberofsoftaces > 0);
}
publicboolean busted(){return total()>21;}
public String toString()
{
//Your code.
}
}
class myRandomextends Random
{
publicint nextInt(int lo,int hi)
{
return lo + nextInt(hi-lo);
}
}
class Deck
{
//Static Member fields
publicstatic myRandom randomizer =new myRandom();
//Member fields
private Card[] cards =new Card[52];
privateint count = 0;
//Constructors
public Deck()
{
//Your code
}
//Mutators
publicvoid fill()
{
//Your code
}
publicvoid shuffle()
{
for (int i=0; i<count; i++)
{
int swapi = randomizer.nextInt(i, count);//i through count-1
Card temp = cards[i];
cards[i] = cards[swapi];
cards[swapi] = temp;
}
}
//Methods
public Card draw()
{
//Your code
}
public Hand[] deal(int numberofhands,int cardsperhand)
{
Hand hands[] =new Hand[numberofhands];
int j;
for (j=0; j>< numberofhands; j++)
hands[j] =new Hand();
for (int i=0; i<cardsperhand; i++)
for (j=0; j>< numberofhands; j++)
hands[j].add(draw());
return hands;
}
}
class Player
{
//Member fields
private String name ="";
private Hand hand =new Hand();
//Constructors
public Player(){};
public Player(String iname){name = iname;}
//Mutator
publicvoid setHand(Hand newhand){hand = newhand;}
//Accessor
publicboolean busted(){return hand.busted();}
publicint total(){return hand.total();}
public String toString()
{
}
//Method
publicvoid play(Deck deck)
{
}
}

