Skip to Main Content

Cloud Platform

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Boolean with "if else" condition help

THELIONHEARTJan 30 2018 — edited Jan 30 2018

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.

Comments

Gary Graham-Oracle

Within the mission scope of the SQL Developer tool, the "drops, ddl + sqlldr table from scratch" approach seems both expected and sufficient.  Expanding the scope to things like replication or data integration, then you would expect to use a different tool.

If your use case for the replicated table is only some kind of testing, look into SQL Developer's Unit Test feature with its Startup and TearDown processing.

Regards,
Gary

SQL Developer Team

Paavo

Thank you very much for your fast response and couraging guidance to try Unit Test which I never tried before. SqlDeveloper and DataModeller are great service for developers!

Unit Test will certainly make testing much easier for me in the future

Of course it was a bit challenging to setup XE where I can act as sysdba and have privilegies to build Unit Test repository etc..

What I have now discovered is that the startup and tear down scripts can be stored to library which can then be copied and optionally subscribed in all unit tests.

Alone this is a very good feature and has pretty polished touch, but one idea came to my mind that could this library be linked with the cart generated export scripts?

That way the Unit Test tear down could contain also ddl-scripts which are not allowed in user plsql-scripts and those could be managed with the cart features of the tool.

The ddl drops and creates for tables, sequences, triggers are necessary because the tear down scripts omit restoring sequences as they were before the unit test took place e.g. for procedures inserting to the tables.

btw. the CART copy-functionality could have similar setup dialog like the export-functionality has, because the copy-functionality attempts to define 'storage' tablespaces and such by default which makes it fail when fiddling between databases.

rgrds Paavo


1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Feb 27 2018
Added on Jan 30 2018
0 comments
433 views