TWiki home XP > XP > ClasseJogada (r1.1 vs. r1.2) XP webs:
Main | TWiki | Sandbox | Portugues
XP . { Bugzilla Últimas atualizações Busca Registro Sobre o TWiki }
 <<O>>  Difference Topic ClasseJogada (r1.2 - 10 Jul 2005 - MeLga)
Line: 1 3 to 1 3
Changed:
<
<
-- AndreChinvelski - 05 Jul 2005
>
>

Line: 268 to 268
Added:
>
>

 <<O>>  Difference Topic ClasseJogada (r1.1 - 05 Jul 2005 - AndreChinvelski)
Line: 1 to 1
Added:
>
>
META TOPICPARENT JogoGeneral
-- AndreChinvelski - 05 Jul 2005

package JogoGeneral;

public class Jogada {

public Tipo jogada;

private int[] facesSorteadas;

private int pontos;

public static enum Tipo {

NORMAL, FULA, QUADRA, SEGUIDA, QUINA

}

public Jogada(int[] dados) {

facesSorteadas = dados;

}

public boolean jogadaEscolhida(Tipo tipo, int qualDupla) {

boolean resposta = false;

switch (tipo) {

case NORMAL:

assert qualDupla>=1&&qualDupla<=6 : "Valor para a dupla deve ser um número que pertença a um dado de seis faces";

resposta = jogadaNormal(qualDupla);

break;

case FULA:

resposta = fula();

break;

case QUADRA:

resposta = quadra();

break;

case SEGUIDA:

resposta = seguida();

break;

case QUINA:

resposta = quina();

break;

}

return resposta;

}

public boolean seguida() {

boolean tem2, tem3, tem4, tem5, resposta;

tem2 = tem3 = tem4 = tem5 = resposta = false;

int oOutroNum = 0;

for (int i = 0; i < facesSorteadas.length; i++) {

if (facesSorteadas[i] == 2) {

tem2 = true;

}

if (facesSorteadas[i] == 3) {

tem3 = true;

}

if (facesSorteadas[i] == 4) {

tem4 = true;

}

if (facesSorteadas[i] == 5) {

tem5 = true;

}

if (facesSorteadas[i] == 1

|| facesSorteadas[i] == 6) {

oOutroNum = facesSorteadas[i];

}

}

if (tem2 && tem3 && tem4 && tem5 && oOutroNum = 0) {

pontos = 35;

resposta = true;

} else {

pontos = 0;

}

return resposta;

}

public boolean quina() {

boolean resposta = false;

if ((facesSorteadas[0] == facesSorteadas[1])

&& (facesSorteadas[1] == facesSorteadas[2])

&& (facesSorteadas[2] == facesSorteadas[3])

&& (facesSorteadas[3] == facesSorteadas[4])) {

pontos = 50;

resposta = true;

}

return resposta;

}

public boolean quadra() {

boolean resposta = false;

int[] aux = { 0, 0, 0, 0, 0, 0 };

for (int i = 0; i < facesSorteadas.length; i++) {

aux[facesSorteadas[i]]++;

}

for (int i = 0; i < facesSorteadas.length; i++) {

if (aux[i] >= 4) {

pontos = 30;

resposta = true;

}

}

if (resposta) {

pontos = 0;

}

return resposta;

}

private boolean fula() {

boolean resposta = false;

boolean temTres, temDois;

temDois = temTres = false;

int[] aux = { 0, 0, 0, 0, 0, 0 };

for (int i = 0; i < facesSorteadas.length; i++) {

aux[facesSorteadas[i]]++;

}

for (int i = 0; i < facesSorteadas.length; i++) {

if (aux[i] ==3) {

temTres=true; }

if(aux[i]==2){

temDois=true; }

}

if (temDois&&temTres) {

pontos = 25;

resposta = true;

}else

pontos = 0;

return resposta;

}

private boolean jogadaNormal(int qual) {

boolean resposta = true;

int quantQual = 0;

for (int i = 0; i < facesSorteadas.length; i++) {

if (facesSorteadas[i] == qual) {

quantQual++;

}

}

pontos = qual * quantQual;

if (quantQual == 0)

resposta = false;

return resposta;

}

public int getPontos() {

return pontos;

}

}


Topic ClasseJogada . { View | Diffs | r1.2 | > | r1.1 | More }
Revision r1.1 - 05 Jul 2005 - 04:54 - AndreChinvelski
Revision r1.2 - 10 Jul 2005 - 22:11 - MeLga
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding XP? Send feedback.