Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is my output, I need the code changes so that instead of numbers it says 1=

ID: 2247460 • Letter: T

Question

  
  

This is my output, I need the code changes so that instead of numbers it says 1="Spades, 2="Diamonds", 3="Hearts, 4="Clubs", and 1=Ace, 11=Jack, 12=Queen, 13=King

Here is the code, please show me how to change this

public class Driver{
public static void main(String[] args)
{
DeckOfCards deck=new DeckOfCards();
System.out.println("Deck of Cards");
deck.printDeck();
  
System.out.println("Shuffling the Deck");
deck.shuffle();
  
Card dealtCard= deck.dealCard();
System.out.println("Card dealt Suit="+dealtCard.getSuit()+
"Face="+dealtCard.getFace());
  
System.out.println("no. of Cards dealt="+deck.getCardsDealt());
  
System.out.println("no. of Cards Left="+deck.getCardsLeft());
}
}

import java.util.Random;

public class DeckOfCards
{

private Card[] deckOfCards;
private int cardsDealt;
private int cardsLeft;
  
  
public DeckOfCards()
{
deckOfCards= new Card[52];
cardsDealt=0;
cardsLeft=52;
  
  
int count=0;
int i,j;
  
for(i=1; i<=4; i++)


{
for (j=1; j<=13; j++)
{
deckOfCards[count++]=new Card(i,j);
}
}
}
  
  
  

public void shuffle()
{ Random randomNumber=new Random();
deckOfCards=new Card[52];
int count=0;
while (count<=51)
{
int suits= randomNumber.nextInt(4)+1;
int face= randomNumber.nextInt(13)+1;
  
boolean found =false;
for (int i=0; i {
if (suits==deckOfCards[i].getSuit() && face==deckOfCards[i].getFace())
{found=true;
}
}
if (found==false)
{deckOfCards[count]=new Card (suits,face);
count++;
}
}
} public void printDeck()
{
for (int i=0;i {
System.out.println("Card" + (i+1) +"Suits=" +deckOfCards[i].getSuit()
+ "Face=" + deckOfCards[i].getFace());
}
}
public Card dealCard()
{
cardsDealt++;
cardsLeft--;
return (deckOfCards[0]);
}
public int getCardsDealt()
{
return cardsDealt;
}
public int getCardsLeft()
{
return cardsLeft;
}}

import java.util.Random;

public class Card
{

private int face;
private int suit;
public Card(int suit, int face)
{
  

this.suit=suit;
this.face=face;
}
public int getFace()
{return face;
}
public void SetFace(int face)
{

this.face=face;
  
}
  
public int getSuit()
{
return suit;
}
  
  
private void setSuit(int suit)
{
this.suit=suit;

}
}
  
  
  

Deck of Cards Card! Suits-1 Face-1 Card2Suits-1Face 2 Card3Suits-1Face 3 Card4Suits-1Face 4 Card5Suits-1Face5 Card6Suits-1Face 6 Card7Suits 1Face-7 Card8Suits-1Face 8 Card9Suits-1Face 9 Card10Suits-1Face 10 Card11Suits-1Face 11 Card12Suits-1Face 12 Card! 3 Suits-1 Face-13 Card14Suits-2Face-1 Card15Suits-2Face-2 Card16Suits-2Face 3 Card17Suits-2Face 4

Explanation / Answer

Modify Card.java to

Card.java

public class Card

{

private static String[] suits={"Spades","Diamonds","Hearts","Clubs"};

private static String[] faces={"Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"};

private int face;

private int suit;

public Card(int suit, int face)

{

this.suit=suit;

this.face=face;

}

public String getFace()

{return faces[face-1];

}

public void SetFace(int face)

{

this.face=face;

}

public String getSuit()

{

return suits[suit-1];

}

private void setSuit(int suit)

{

this.suit=suit;

}

}

  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote