1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
#include<iostream>
#include<vector>
using namespace std ;
class Coordonnee {
public:
Coordonnee():ligne(0),colonne(0){};
Coordonnee(int x, int y):ligne(x),colonne(y){}
void setCoordonnee(int x , int y);
void setLigne(int x);
void setColonne(int y);
int getLigne();
int getColonne();
~Coordonnee();
private :
int ligne ;
int colonne ;
};
void Coordonnee::setCoordonnee(int x , int y){
ligne = x;
colonne = y ;
}
void Coordonnee::setLigne(int x){
ligne = x;
}
void Coordonnee::setColonne(int y){
colonne = y ;
}
int Coordonnee::getLigne(){
return ligne ;
}
int Coordonnee::getColonne(){
return colonne;
}
class Piece {
public:
Piece():place(0,0){};
Piece(int x , int y);
void AffichagePiece();
~Piece();
// virtual ~Piece();
protected :
Coordonnee place ;
};
Piece::Piece(int x , int y){
place.setLigne(x);
place.setColonne(y);
}
//virtual void AffichagePiece();
class Pion : public Piece {
public:
Pion():Piece(0,0),couleur(1),etiquette('R'){};
Pion(int x , int y , char coul , char etiq);
~Pion();
//virtual ~Pion();
void deplacer(int x , int y);
char getEtiq();
void AffichagePiece();
private :
int couleur ;
char etiquette ;
};
Pion::Pion(int x , int y , char coul , char etiq){
Piece(x,y);
couleur= coul;
etiquette= etiq;
};
void Pion::deplacer(int x , int y){
int m = place.getLigne() + x ;
place.setLigne(m);
int z = place.getColonne()+ y ;
place.setColonne(z);
}
char Pion::getEtiq(){
return etiquette;
}
void Pion::AffichagePiece(){
cout << this->getEtiq() ;
}
class Plateau {
public :
Plateau();
~Plateau();
void Affichage();
void AffichageCase();
private :
vector <Piece*> SS ;
};
Plateau::Plateau(){
Piece *P1 = new Piece();
Piece *P2 = new Piece(1,2);
Pion *Tour = new Pion(4,3,'N','T');
Pion *Roi = new Pion(5,4,'B','V');
SS.push_back(P1);
SS.push_back(P2);
SS.push_back(Tour);
SS.push_back(Roi);
}
void Plateau::Affichage(){
for(int i= 0 ; i< 8;i++){
for(int j = 0 ;j<8;j++){
this->AffichageCase();
}
}
vector <Piece*>::iterator i ;
for(i=SS.begin();i!=SS.end();i++){
(*i)->AffichagePiece();
}
}
void Plateau::AffichageCase(){
cout << "_" ;
}
int main (){
Plateau P1 ;
P1.Affichage();
return 0 ;
} |