0
Good afternoon guys, I’m doing the General’s game (java dice). I am in doubt on how to compare the data between them.
Sequel 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 different from y) Number of points: ( 3 * x + 2 * y ) + 30
Court 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 has the following sequence of numbers: 2 3 2 2 5
So far I’ve been able to take the test to see if you’re a 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 someone give me some hint how to make the other comparisons? Thanks in advance!
Very good tip! Thanks @Piovezan
– Maurício Z.B
Problem is that this giving exceeded limit on the vector, I put the code there in the chat if you can help me. java.lang.Arrayindexoutofboundsexception
– Maurício Z.B
Remember that an array that has for example 5 elements will have indexes from 0 to 4. In the code you posted for example you should not do what is up to q < 5 but up to q < 4 because the data[q+1] will exceed the size of the array.
– Piovezan