Jump to content

Recommended Posts

Posted

Boas pessoal.

Estou a fazer um trabalho em JAVA, e é para ser executado em AGUIAJ. Eu tenho de fazer um jogo de cartas...

Para tal eu já construí o baralho e já o baralhei, o que não consigo é distribui as cartas pela nº de jogadores (variável que o utilizador coloca, entre 2 e 8 )...

Alguém me pode ajudar?

Obrigado desde já!

Posted

É só tirares cartas do baralho. Se estiveres a utilizar um stack para simular o baralho não é suposto teres grandes dificuldades. Se não estás, então é porque não escolheste bem a estrutura que devias utilizar.

“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”

-- Tony Hoare

Posted

Eu tenho uma coisa deste género, o que sobrar da distribuição é que vou meter num stack para simular o monte de bisca!

mas este código dá-me um erro na parte :

                "jogadores[a] = new Jogador (a, maoJogador);

maos[a] = jogadores[a].ObterMaoDoJogador();"

public static CardHand[] DarCartas(int nJogadores) {

Card[] baralho = Baralhar(Baralho());
CardHand[] maos = new CardHand[nJogadores];
CardHand maoJogador;

for(int a = 0; a < nJogadores; a++){
	maoJogador =  new CardHand();

	for(int i = 0; i < 5; i++)
		maoJogador.add(baralho[i]);

		for(int j = 0; j < baralho.length-1;j++)		
			baralho[j] = baralho[j+1];

	jogadores[a] = new Jogador (a, maoJogador);
	maos[a] = jogadores[a].ObterMaoDoJogador();
}
return maos;
}

Se me conseguires explicar como devo usar o stack agradecia!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.