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

I need help coding a video poker game in java. First off: I don\'t know how to s

ID: 3939910 • Letter: I

Question

I need help coding a video poker game in java. First off: I don't know how to sort a hand (5 cards) by rank value. This is what I tried:

void JButton2_actionPerformed(java.awt.event.ActionEvent event)

{

  

  

   for (int i = SIZE_OF_HAND; i > 0; i--){

          

       for (int j = 0; j < i - 1; j++){

           Card c1 = myHand.getCard(j);

           Card c2 = myHand.getCard(j + 1);

              

           Card temp = c1;

              

           if (c1.compareTo(c2) > 0) {

               c1 = c2;

               c2 = temp;

                  

           }

              

              

              

              

       }

   }

and I also tried this:

   myHand.sort();

          

where .sort() is defined in the class Hand as:

public void sort() {

      Collections.sort(hand);

  

      

}  

None of these methods work. This is pretty urgent, so please help! Thanks.

Explanation / Answer

Hand.java package javapoker; public class Hand { private Card[] cards; private int[] value; Hand(Deck d) { value = new int[6]; cards = new Card[5]; for (int x=0; x=2; x--) { if (ranks[x]==1) { orderedRanks[index]=x; //if ace index++; } } for (int x=1; x
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