Forum Stats

  • 3,733,039 Users
  • 2,246,686 Discussions
  • 7,856,490 Comments

Discussions

Boolean with "if else" condition help

THELIONHEART
THELIONHEART Member Posts: 1
edited January 2018 in Java Cloud Service

Hey everyone, I'm having trouble with this boolean "if else" condition assignment and I was wondering if you guys could help me out?

So here's the assignment question "

The complete hand classifier for poker would be far too complicated for us to write in this course, so let’s just look at a couple of instructive special cases. First, write a method boolean hasFlush(String hand) that checks whether the five-card poker hand given as 10-character string is a flush, that is, all five cards are of the same suit. Ranks don’t matter for this problem, since for simplicity, we don’t care about the rare possibility of straight flushes. (Hint: The suits are given in the positions 1, 3, 5, 7 and 9 of the parameter string.) "

With that question he also gave us a tester to use to help guide us. which is

      @Test

    public void testHasFlush() {

        java.util.Random rng = new java.util.Random(SEED);

        Adler32 check = new Adler32();

        for(int i = 0; i < RUNS; i++) {

            String hand = createHand(rng, 5);

            check.update(cp.hasFlush(hand) ? i : ~i);

        }

        assertEquals(1990048361L, check.getValue());

    }

Here is the code that I was able to create.

    public static boolean hasFlush(String hand){

       

        if (hand == "d2d4d6d9d10") {return true;}

        else {return false;}

       

    }

          

I'm not to sure what I did wrong but when I complied it, I had no syntax errors. However, when i tried to test the program and tried inputting d2d4d6d8d10 i got " Error ';' expected" and when i tried to test it with my teacher's tester, I gave said "Failed Test, debug"

Can you guys correct me on what i did wrong?

Thank you in advanced.

P.S I use BlueJ to do this Java assignment.

Tagged:
This discussion has been closed.