General Game in Java

0

Good afternoon guys, I'm doing the General game (of data in Java). I am in doubt on how to compare the data between them.

Sequence Possible sequences: 1-2-3-4-5 / 2-3-4-5-6 / 3-4-5-6-1 Number of points: 20

Full-Hand The number x in 3 data and the number y in the remaining two (for x other than y) Number of points: (3 * x + 2 * y) + 30

Quadra The number x in four different data Number of points: (4 * x) + 40

General The number x in the five dice Number of points: (5 * x) + 50

Simple Combinations For each number from 1 to 6 the player can score points as in the example: Ex: If the player obtains the following sequence of numbers: 2 3 2 2 5

So far I've been able to test to see if it's General:

 public int VerificarDados()
{
    int aux=1;
    int q=0,u;
    for(q=0;q<5;q++)
    {
        if(dados[q]==dados[q+1])
        {
            aux++;
        }
    }
    numRept=dados[1];
    if(aux==5)
    {
        return 5; //general
    }

Could anyone give me any tips how to make the other comparisons? Thank you!

    
asked by anonymous 18.05.2018 / 21:21

1 answer

1

Save in a 6-element array the number of occurrences of each data (example: if three numbers 1 were left, store the number 3 in the first house of the array, if there were four numbers 6, save in the last house of the array the value 4).

Then you go through the array in search of each condition you want (look for the occurrence of 5 numbers, if you find it is a General, look for the occurrence of 3 numbers and the occurrence of 2 numbers if you find the two is Full- hand, otherwise it is a simple combination, and so on.

    
18.05.2018 / 22:02