Created
September 7, 2009 19:26
-
-
Save brunopedroso/182527 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(i = 0; i < tamanho; i++){ | |
frame ++; | |
//terceira bola do ultimo frame | |
if (frame == 11) { | |
return resultado; | |
} | |
//verifica se o frame esta completo | |
if((i+1 < tamanho)) { | |
//detecta o spare | |
if (arrayJogadas[i] + arrayJogadas[i + 1] == 10) { | |
//se existe uma bola depois do spare | |
if (i+2 >= tamanho) { | |
//caso nao consiga calcular | |
return -1; | |
//calculo do spare | |
} else { | |
resultado += arrayJogadas[i] + arrayJogadas[i + 1] + arrayJogadas[i + 2]; | |
} | |
//jogada normal, frame completo | |
} else { | |
resultado += arrayJogadas[i]; | |
resultado += arrayJogadas[i+1]; | |
} | |
//esta consumindo o frame completo | |
i++; | |
//frame incompleto, nao consegue calcular | |
} else { | |
return -1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment