Java: Yacht test is confusing / wrong

Created on 15 Oct 2018  路  5Comments  路  Source: exercism/java

Hi,

I was working on the Yacht game exercise.

In the problem introduction, an example is given regarding to category not applying to dice values:

If the dice do not satisfy the requirements of a category, the score is zero. If, for example, Four Of A Kind is entered in the Yacht category, zero points are scored. A Yacht scores zero if entered in the Full House category.

This text seems to mean that with dice values like { 3, 3, 3, 3, 3 }, Four Of A Kind should return a score of zero.
In the test suite, there is a test named yachtCantBeScoredAsFourOfAKind. This name seems to exist to ensure a zero score in this specific case.

However, this test expects a non-zero value:

    @Test
    public void yachtCantBeScoredAsFourOfAKind() {
        Yacht yacht = new Yacht(new int[]{ 3, 3, 3, 3, 3 }, YachtCategory.FOUR_OF_A_KIND);
        assertEquals(12, yacht.score());
    }

I may be misunderstanding the problem, or this test is wrong.
Either way, I think something has to be done to correct or clarify this specific case of Four Of A Kind with a Yacht dice result.

In the linked Wikipedia page to the Yacht game, it is written that _芦At least four dice showing the same face禄_ is the rule to match a Four Of A Kind category.

Ask me if you need me to make a PR, once we decide what should be done :)

All 5 comments

@rvictorino First, you are right, the method name is misleading/wrong. It should be yachtCanBeScoredAsFourOfAKind.

Other than that the test is working correctly.

If the dice do not satisfy the requirements of a category, the score is zero. If, for example, Four Of A Kind is entered in the Yacht category, zero points are scored. A Yacht scores zero if entered in the Full House category.

The input here would be for example {3, 4, 4, 4, 4}, Category: Yacht. Obviously, the input of numbers does not satisfy the criteria for being scored as yacht. That is why you would receive 0 points, also clearly you would satisfy the four of a kinds criteria.

The test works as followes yachtCanBeScoredAsFourOfAKind: You have {3, 3, 3, 3, 3} as input, as well as the category "four of a kind". Although the numbers would also satisfy the criteria for yacht, you only receive 12 points because you put the category four of a kind.

Thank you, nice work !
I can see you fixed the test to allow Four Of A Kind when input is a Yacht.
In that case, wouldn't it be nice to also edit the execise introduction to match this test:

If, for example, Four Of A Kind is entered in the Yacht category, zero points are scored

We could either remove / replace this example, or edit it to give example of a non-zero score when input is expected to perfectly match a category (e.g. Yacht) but it is asked to calculate with another category (e.g. Four Of A Kind) which also matches the input.

@rvictorino The exercise description is specified in the problem specifications repo. If you have any suggested changes please open an issue in that repo as we can't change it just for this track 馃檪

Oh, right!
Will do !
Thanks for your help and time :)

No problem, thanks for brining this to our attention! 馃檪

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lemoncurry picture lemoncurry  路  3Comments

FridaTveit picture FridaTveit  路  6Comments

FridaTveit picture FridaTveit  路  6Comments

himanshugoyal1065 picture himanshugoyal1065  路  4Comments

FridaTveit picture FridaTveit  路  6Comments