Exemple #1
0
void Interface::MostraTabuleiro(Tabuleiro Mesa)
{
    int linha,coluna;

    cout<<"| A  | B  | C  | D  | E  | F  | G  | H  |"<<endl;

    for(linha=0;linha<=7;linha++)
    {
        cout<<linha+1<<"\t"<<endl;

        for(coluna=0;coluna<=7;coluna++)
        {
            if(Mesa.GetDadosCasa(linha,coluna)->GetPedra()==NULL)
            {
               cout<<"|____"/*<<endl*/;
            }
            else
            {
                if(Mesa.GetDadosCasa(linha,coluna)->GetPedra()->GetCor())
                {
                        if(Mesa.GetDadosCasa(linha,coluna)->GetPedra()->GetEhDama())
                        {
                                cout<<"|_DB_"/*<<endl*/;
                        }
                        else
                        {
                                cout<<"|__B_"/*<<endl*/;
                        }
                }
                else
                {
                        if(Mesa.GetDadosCasa(linha,coluna)->GetPedra()->GetEhDama())
                        {
                                cout<<"|_DP_"/*<<endl*/;
                        }
                        else
                        {
                               cout<<"|__P_"/*<<endl*/;
                        }
                }

            }

        }
        cout<<"|\n"<<endl;
    }
}
Exemple #2
0
jogo* arqtexto::Carregar(void) {
    try{
        this->LeArquivo(persistencia);
        
        Tabuleiro *Partida = new Tabuleiro();
        Casa *casa = new Casa();
        Pecas *pedra = new Pecas();
        jogo *Salvo = jogo::getInstance();

        int cor,dama,linha,coluna;

        while(!persistencia.fail())
        {

            persistencia>>cor;
            persistencia>>linha;
            persistencia>>coluna;

            if(cor=='22' && Partida->GetDadosCasa(linha,coluna)->GetPedra()!=NULL){
                Partida->GetDadosCasa(linha,coluna)->SetPedras(NULL);
            }
            else if(cor!='22')
            {
                persistencia>>dama;

                if(this->CorPedra(linha,coluna,Partida)!=cor || this->StatusPedra(linha,coluna,Partida)!=dama){
                    Pecas *pedra = new Pecas(cor);
                    //pedra->ehDama = dama;
                    Partida->GetDadosCasa(linha,coluna)->SetPedras(pedra);
                }
            } 
         }

        Salvo->tab=Partida;
        return Salvo;
    }