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

Program 2b: CardDeck in Java. Hello Chegg, I have been tyring to complete this l

ID: 3750291 • Letter: P

Question

Program 2b: CardDeck in Java.

Hello Chegg,

I have been tyring to complete this lab for quite some time now but now I found myself sstuck and was wondering if I could get assistant to finsh this class. I also attached (the bottom) my own code, and I am hooping we could use it to finsh the rest.

Thank You so much! ( I always rate positively ) ..... :)

Rolling with the same theme, we are going to focus on the characteristics and functionality of a deck of cards. In this program you will be creating a "CardDeck.java" file in your IDEs that will have the following characteristics:

Class Variables:

These arrays will be important, and for that reason I want you to put the "ranks" and "suits" array in your code EXACTLY as you see it above. When we populate our deck we are going to store each card exactly as we say them, for example "Ace of Spades" or "3 of Clubs".

public CardDeck(), this will be your constructor for your class and will be where you fill your "deck" array.
This one is going to be a bit tricky to populate but I know you guys can do it. I'm going to give you some hints to get started. For starters, use a for-loop within a for-loop, one for the ranks and one for the suits. Initialize the index tracker of the "deck" array OUTSIDE of these for-loops. Remember to store each card in "deck" as you say it: "rank" of "suit". I know this is going to be tricky but come by office hours of either the TAs or Professor Kraft we are going to be here to help you all.

public String getCard(int index), return the card at the given index.

public String getFirst(), return the first card in "deck".

public String getLast(), return the last card in "deck".

public String royalFlush(), return a String of cards that are contained in a Royal Flush poker hand. If you don't know what a Royal Flush consists of, you can give it a quick google search and you'll be able to figure it out. But the way I would like you to return it is all the cards on one line with a comma then a space in between each card.

public class CardDeck {
   public String[] ranks = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"};
   public String[] suits = {"Clubs", "Diamonds", "Hearts", "Spades"};
   private int deckNum = 52;
   public String[] deck = new String [deckNum];
   public CardDeck () {
       for (int i = 0; i < ranks.length - 1; i++) {
           for (int j = 0; j < suits.length - 1; j++) {
               do (int t; t < deckNum; t++) { //area where I got stuck
                   deck [i] = ranks [i] + suits [j];
               }
           }
       }
   }
   public String getCard (int index) {
       return deck [index];
   }
   public String getFirst () {
       return deck [1];
   }
   public String getLast () {
       return deck [deckNum - 1];
   }
   public String royalFlush () {
      
   }

Explanation / Answer

Hi, I have fixed the code where you have commented that you are stuck:

If you need any other help please let me know.

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