2E Blackjack! Design a class called “Card” that models a playing

2E Blackjack! Design a class called “Card” that models a playing card. Decide
what instance variables you will need for this class in order to play Blackjack (or any other card
game.) Include a zero-argument constructor and the appropriate multi-argument constructor for
your class. It should also have a toString() method to display ALL of the object’s instance
variables in a user-friendly format…this can be a bit tricky…
Write a CardDriver that will perform the following tasks:
a) Create three Card objects: a blank card (i.e. a Card created using its zeroargument constructor), a “number” card, and a “face” card…you pick the
cards.
b) Create an array called “myHand” that can hold 3 Card objects.
Below are the lines of code that demonstrate how to create an array of Card objects and how to
place a Card object into an array called myHand.
Card[] myHand = new Card[10]; Card card1 = new Card( 10, ‘‘Jack’’, ‘‘Hearts’’ ); myHand[0] =
card1;
c) Use a for loop to traverse the array of your Cards and print each Card using
System.out.println().
public class Card
{
private int cardNumber;
private String face;
private boolean isNum;
public Card()
{
cardNumber = 0;
face = " ";
isNum = true;
} // end zero constructor Card
public Card( variable 1, variable 2, variable 3 )
{
this.variable 1 = variable 1;
…
…
} // end three argument constructor Card
public String toString()
{
String cardInfo = new String();
if(variable 3 == true )
{
cardInfo = " ____\n" +
"|" + cardNumber +" |\n" +
"| |\n" +
"| |\n" +
"| " + cardNumber +"|\n" +
"'----'";
} // end if
else
{
cardInfo = " ____\n" +
"|" +face+" |\n" +
"| |\n" +
"| |\n" +
"| " + face +"|\n" +
"'----'";
public class CardDriver
{
public static void main( String[] args )
{
// chooses a number randomly
int chooseNumber = ( int )( 1+ Math.random() * 10 );
// chooses a face randomly (from an array)
String chooseFace = new String();
String[] faces = new String[3];
faces[0] = "K";
…
…
chooseFace = faces[ ( int )( Math.random() * 3 ) ];
// creates the cards
Card blank = new Card();
Card numberCard = new Card( chooseNumber, chooseFace, true );
Card faceCard = new Card( chooseNumber, chooseFace, false );
// creates the deck
Card[] deck = new Card[3];
deck[0] = blank;
deck[1] = numberCard;
deck[2] = faceCard;
// prints the deck
for( int index = 0; index < deck.length; index++)
{
System.out.println( deck[index] );
} // end for
} // end method main
} // end CardDriver
P2F. Write a program that creates an array that can hold 9 double values that represent baseball
batting averages for a starting baseball lineup. Use a for loop to
populate array with double values in the range of 0.00 to 0.500. Recall that “double” values are
what Java calls “real” numbers. Use a second for loop to print the values in
the array with one number per line. Finally, use a third for loop to traverse the array and find and
print the maximum batting average in the array. See the LewTube for this HW assignment to see
how to control the precision of a double number when you print it.
public class
{
public static …
{
double[] numbers = new double[10];
double highNumber = 0;
for( int ??? = 0; index < numbers.length; index++ )
{
numbers[???] = 100 - Math.random() * 200;
} // end first for
for( int ??? = 0; index < numbers.length; index++ )
{
System.out.println( numbers[index] );
} // end second for
for( int index = 0; index < numbers.length; index++ )
{
if(??? == 0)
{
???? = numbers[ index ];
} // end if
if( numbers[ ???? ] > highNumber )
{
???????????? = numbers[ ???? ];
} // end if
} // end third for
System.out.println( "\nThe largest number is " + highNumber );
} // end method main
} // end class ArrayDoubles