Tenho que fazer a classe de teste da classe que estou passando abaixo, mais nao sei como fazer gostaria da
ajuda de voces para conseguir isso.
[code]package br.com.ffm.info.map.game;
import java.util.ArrayList;
import br.com.ffm.info.map.exception.GameExceptionTabuleiro;
import br.com.ffm.info.map.factory.BeatleConcret;
/**
*Entidade Game que controla amovimentação dos besouros, contem as regras do jogo, inicia o jogo e inicia a construção do tabuleiro
*/
public class Game {
private Table table = null;
//private static Game gameUnicaInstancia = null;
/**
*Metodo que inicia o game
*/
public Game(){
}
/**
*Metodo que cria os tabuleiros
*
*/
public void startTable() {
table = new Table();
}
/**
*Método responsavel por mover os Beatle
*/
public void gameMove() {
ArrayList<Celula> celulas = table.getCelulas();
for (Celula celula:celulas){
if ((celula.estaVazia()==false)){
boolean aloca = false;
while (!aloca){
Celula celulaVazia = table.celulaVazia(1+(int)(Math.random() * 8),1+(int)(Math.random() * 8));
if (celulaVazia.estaVazia()){
aloca = true;
celulaVazia.alocaBesouroCelula(celula.getBeatleConcret());
celula.setBesouroDestroy();
System.out.println("Besouro foi movido para "+celulaVazia.getPosicaoX()+","+celulaVazia.getPosicaoY());
}
}
}
}
}
public void gameController() throws GameExceptionTabuleiro {
// this.startTable();
while(table.quantidadeBesourosGame()>1){
this.gameMove();
this.gameExecuteActionBeatle();
this.destroyBeatle();
}
}
public void gameExecuteActionBeatle(){
ArrayList<Celula> celulas = table.getCelulas();
for (Celula celula:celulas){
if(celula.estaVazia()==false){
BeatleConcret besouro = celula.getBeatleConcret();
besouro.executeAction(this, celula);
}
}
}
/**
* Pega os vizinhos passando as coordenadas do besouro
* @param x
* @param y
* @return
*/
public ArrayList <BeatleConcret> getVizinhos(int x, int y) {
ArrayList<Celula> celulas = table.getCelulas();
ArrayList<BeatleConcret> besouros = new ArrayList<BeatleConcret>();
for (Celula celula:celulas){
if ((celula.getPosicaoX()-x == 1)&&(celula.getPosicaoY()-y == 1)){
if (celula.estaVazia() == false){
besouros.add(celula.getBeatleConcret());
}
}
}
return besouros;
}
/**
* adiciona o besouro no tabuleiro
* @param besouro
*/
public void addBeatleGame(BeatleConcret besouro) {
table.addBesouroTabuleiro(besouro);
}
/**
* Tira um besouro do jogo;
*/
public void destroyBeatle() {
ArrayList<Celula> celulas = table.getCelulas();
for(Celula celula:celulas){
if(celula.estaVazia() == false){
BeatleConcret besouro = celula.getBeatleConcret();
if(besouro.getLife()<0){
celula.setBesouroDestroy();
}
}
}
}
}
[/code]
agradeço a ajuda de todos,